As part of the multiyear deal, Comcast, the country's largest cable TV operator, also agreed to buy Disney's 39.5 percent stake in the E! Entertainment Television channel for $1.23 billion. Comcast currently holds a 60 percent interest in the channel.
No other financial terms of the deal were disclosed.
Under the terms of the agreement, Comcast would spend about $1 billion annually to purchase programming such as the popular ABC shows "Desperate Housewives" and "Lost," as well as other content from ESPN, the Disney Channel and Toon Disney, according to a person close to the deal who spoke earlier on condition of anonymity because it had not been formally announced.
The deal extends a content distribution agreement for the 10 ABC-owned broadcast television stations and many of Disney's TV networks, including Disney Channel, ABC Family, Toon Disney, ESPN, and ESPN2, among others, the companies said.
As part of the agreement, Comcast will launch a Spanish-language sports network dubbed ESPN Deportes, the companies said.
Disney has agreed to allow Comcast to distribute episodes of "Desperate Housewives," "Lost" and two unspecified new fall programs through the on-demand service for free within 12 hours of airing. The cable giant will also add "World News with Charles Gibson," "Nightline" and "This Week" to its on-demand roster.
"This is one of the broadest distribution agreements in the history of our company," Disney President and CEO Robert Iger said in a prepared statement.
Added Comcast Chairman and CEO Brian Roberts: "This agreement reflects our ability to distribute content on multiple platforms and signals another first for Comcast and Disney as we continue to explore the evolving possibilities of digital technology."
The deal is a big prize for Comcast, because it gives the company access to Disney, Miramax and Touchstone movies, with new releases available to customers for $3.99 and older ones for $2.99. Titles will include "Pirates of the Caribbean: Dead Man's Chest" and "The Prestige," among others.
The two companies have been linked for a long time. In 2004, Comcast proposed buying Disney for about $54 billion in stock, but Comcast withdrew its bid after twice being rebuffed by Disney.
Disney said previously it was negotiating new multiyear deals with Comcast and Time Warner Cable.
The talks have dragged on for years and been delayed as media companies experiment with new ways to deliver content to consumers, including selling TV episodes online and offering free, advertising-supported streaming versions on network Web sites.
Cable companies have said they want to offer TV shows on demand for 99 cents per episode and show movies on demand the same day they become available on DVD, instead of weeks later.
Disney has been renegotiating its cable deals in recent years, favoring longer terms that provide a steady stream of income.
Earlier this year, Comcast, CBS Corp. and General Motors Corp. tested the concept of showing prime time TV shows on-demand for free for digital cable subscribers in Philadelphia, Baltimore, Chicago and Detroit.
CBS already offers prime time shows such as "Amazing Race," and "CSI: Crime Scene Investigation" through Comcast's video-on-demand network for 99 cents each.
Video on demand lets digital subscribers watch archived shows and movies at any time.
Shares of Walt Disney climbed 11 cents on the New York Stock Exchange to close at $33.23, near the upper-end of its 52-week trading range of $23.77-$33.85. Shares of Comcast declined by 11 cents on the Nasdaq Stock Market to $40.68, near the upper-end of its 52-week trading range of $25.35-$41.20.