After a long night of negotiations, Viacom and Dish have come to terms on a carriage agreement that will make some Viacom channels available through Dish’s low-cost Sling TV streaming service for the first time.

The sides had faced the threat of a blackout as the previous contract expired at midnight ET Wednesday.

Financial details on the deal were not disclosed. But Dish appears to have prevailed in the standoff as it had been seeking an agreement that would allow Viacom’s biggest brands to become part of its Sling TV service. The multi-year pact will see Comedy Central, BET, Spike, MTV and Nick Jr added to the Sling lineup, although the mothership Nickelodeon channel does not appear to be part of that agreement.

“We appreciate Viacom’s willingness to continue with us on our journey as we work to deliver the best, most innovative television services available,” said Charlie Ergen, Dish chairman-CEO. “This creative, bold and consumer-friendly approach extends a nearly 20-year-old relationship.”

The threat of a prolonged blackout on Dish, which has about 13.8 million subscribers, promised to be costly for both sides. The general consensus among Wall Street analysts was that Viacom could ill afford to lose the affiliate revenue even if Dish drove a hard bargain on fees and demanded new rights as part of a multi-year renewal deal. Viacom shares on Thursday made up all of the losses and then some suffered on Tuesday as the deadline for the deal approached. Shares were up 13.8% at the close of trading Thursday to $42.56, after slumping 8% on Tuesday.

“Today’s agreement ensures Viacom’s number one family of networks will continue to be available to our millions of fans on DISH and underscores the value of our programming across platforms,” said Viacom chairman-CEO Philippe Dauman. “DISH has historically been and remains an important partner for Viacom, and as part of our commitment to entertain audiences wherever they are, we are pleased to offer select Viacom networks as part of DISH’s Sling TV product. Today’s renewal, together with several additional affiliate agreements announced over the past year, will enable Viacom to drive growth and deliver better, more engaging viewer experiences for years to come.”

The scrutiny of Viacom and Dish’s renewal negotiations has led to speculation that a modest fee agreement with Dish to avoid going dark would make it harder for Viacom to drive higher fees in future negotiations with other MVPDs. Viacom issued a statement following the Dish renewal announcement addressing that issue head-on.

“In addition to today’s DISH renewal, in the past year Viacom has successfully closed long-term domestic distribution agreements with AT&T, Charter, Frontier, Mediacom and several regional distributors, representing more than 44 million subscribers in total,” a Viacom spokesman said. “In 2017 and beyond, these deals will drive Viacom’s annual affiliate fee growth with our traditional distribution partners at solid mid-single-digit rates.”