Cable giant Comcast Corp. has reached an agreement to continue carriage of Fox News Channel, the two companies said, averting a blackout that would have left millions of viewers without access to the popular network.

As part of the deal, Comcast CMCSA, +0.75% and Fox News-parent 21st Century Fox FOX, +2.86% have also come to terms on a new distribution agreement for Fox’s YES regional sports network, which is home to the New York Yankees. Comcast stopped carrying YES in late 2015 because of a contract dispute.