UPDATED: Days after the CW unveiled to advertisers its 2016-17 lineup last Thursday, the network has closed a new deal with its biggest affiliate group, Tribune. The down-to-the wire new agreement assures that the CW will continue to be carried by the Tribune stations in 25% of the country, including the top two markets — New York and Los Angeles. Meanwhile in the No. 3 market, Chicago, the CW affiliation will switch from Tribune’s WGN-TV to the Fox Television Stations-owned WPWR, beginning on September 1. I hear the new agreement is for 5 years. (Tribune’s original affiliate deal with the CW was for 10 years.)

WGN, which will now become independent, is very sports-focused. It has a slate of more than 150 live Cubs, Sox, Bulls and Blackhawks games. That has led to a slew of pre-emptions of the CW while WGN has had to move as many as 30 games a year to another local station in Chicago.

“As an indepeTribune Media logondent television station, we’ll have the opportunity to bring more primetime baseball, basketball and hockey games to Chicago sports fans on weeknights, add some popular syndicated programming, expand our weekend morning news, and take control of all of WGN- TV’s primetime advertising inventory,” said Larry Wert, President of Broadcast Media for Tribune Broadcasting. “Importantly, we’ll also avoid having to move any games off of WGN-TV to accommodate network programming.”

Locking in a new deal with Tribune was crucial for the CW as it is about to start selling advertising for next season on the upfront market. And the CW announced at its presentation that starting this fall, the CW app will be available on more than 80 million devices without authentication. (The companies’ previous deal is up in August.)

The CW’s owners, CBS and Warner Bros, had been hoping to have an affiliate agreement secured by Supergirl 3the upfronts. While that didn’t happen, negotiations with Tribune had been going well recently. As the CW on Thursday unveiled to advertisers its most ambitious schedule yet, featuring 15 original scripted series, including high-profile transplant Supergirl, there were indications that a deal was imminent.

“As The CW continues to build on its current ratings momentum and full schedule of high-quality programming, we are thrilled to continue our successful partnership with Tribune and their affiliated stations for many years to come,” said Mark Pedowitz, President, The CW Network.

Added Peter Liguori, Tribune Media’s President and CEO. “We are extremely pleased to continue our strong relationship with The CW Network. The primetime entertainment programming offered by The CW drives a passionate and loyal audience to our stations and we are looking forward to a lot of success.”

It was on the day of the CW upfront presentation in 2014 when Liguori made headlines with his pointed comments about being “not pleased” with the CW. Things have somewhat normalized since that low point in the relationship, but the affiliate renewal talks nevertheless were difficult, for the most part going slowly, even stalling at times, which has caused a lot of frustration.

While Tribune had a stake in the CW predecessor the WB, the company has no ownership in the CW, thus making the companies’ relationship a standard affiliate agreement where financial terms needed to be reached.

Flash ArrowDespite an overall ratings slip in the fall — due to the performance of shows like freshman Crazy Ex-Girlfriend, whose ratings were soft, and veteran The Vampire Diaries, whose season-to-season decline were been bigger than expected — the CW has done OK overall, launching another solid performer in January with DC’s Legends of Tomorrow and improving Friday with the move of TVD there. The network is in a much stronger position with affiliates than it was a couple of years ago, with a broader, older, balanced female-male audience and ratings hits like The Flash and Arrow as well as critically-praised and award-winning shows like Jane the Virgin and Crazy Ex-Girlfriend.

“The CW had its best season ever,” the network’s head of sales Rob Tuck said at the top of the upfront presentation last week. It now is adding CBS‘ Supergirl to its lineup next fall.

Fox TV Stations logo“We love high quality, big budget first-run prime and we love having more original programming, said Frank Cicha, SVP of Programming of Fox Television Stations. “But most of all, we love moving to The CW the same time as Supergirl.”

Tribune was one of several station owners whose affiliate deals with the CW were up this year. The others, including Sinclair and Media General, renewed their agreements months ago, leaving Tribune as the only holdout.

While there were alternative scenarios both sides had been exploring should a new deal is not reached, observers had agreed that re-upping would be good for both companies.

Complicating matters was Tribune’s March announcement that it had taken a big write-down on its TV operations and had hired two financial advisers to explore “strategic and financial alternatives” including asset sales.

Company insiders as well as Wall Street sources insisted at the time that the developments should not impact the renewal talks with the CW. “Liquidity is not an issue,” said Moody’s Investors Service VP Carl Salas. “This is a solid company.”