About six years ago, Metro-Goldwyn-Mayer Studios, the mini-major Hollywood studio, was bankrupt. Its film slate was in tatters, and financing was tenuous.

My, times have changed. On Wednesday, MGM said it would pay Viacom (VIAB - Get Report) and Lions Gate Entertainment (LGF.A - Get Report)  a total of $1.03 billion to take full ownership of the Epix premium cable network. MGM views Epix's four traditional pay-TV channels as a means to increasing its production of TV serials while providing wider distribution for its film library, which includes the James Bond franchise, The Wizard of Oz, Jaws and E.T. the Extra-Terrestrial.

A deal was said to be close last month, and TheStreet included an MGM buyout of its Epix partners in a media predictions piece in December. TheStreet earlier in December said Epix's owners were considering an IPO but also had received outside interest, although no talks were ongoing.

Viacom owns about 49.8% of Epix while Lions Gate's stake is around 31.2%.

The MGM transaction, which values Epix at $1.28 billion, fulfills immediate needs for both Viacom and Lions Gate while giving MGM a platform to showcase its burgeoning television business. MGM's recent serials include Fargo on FX, Vikings on History and Teen Wolf on MTV, and its The Handmaid's Tale is set to debut on Hulu later this month. In the coming months, it is likely that MGM will consider launching Epix as a standalone subscription service similar to HBO Now from Time Warner (TWX) and Showtime from CBS (CBS - Get Report) .

The deal also allows Viacom and Lions Gate to receive cash for an asset that was no longer central to their business. Vicaom CEO Bob Bakish has made clear that his company's primary focus is on its six largest cable TV networks and Paramount Pictures. Lions Gate was also a motivated seller, having acquired Starz, a rival premium cable TV channel, last year for $4.4 billion.

For 92-year-old MGM, based in Beverly Hills, Calif., Epix has the potential to raise its profile under CEO Gary Barber. MGM need only look at CBS's success in bolstering Showtime's programming slate in recent years to appreciate the possibilities for a souped-up and better-managed Epix. MGM's film library also includes The Hobbit, Rocky, RoboCop and Pink Panther series.

MGM has gone from declaring bankruptcy in November 2010, when total long-term debt exceeded $4 billion, to having almost no debt while generating earnings, excluding some costs, of $400 million to $500 million. MGM's earnings for 2015 totaled $401 million, the company said March 9 in a corporate filing.

The studio exited Chapter 11 in December 2010.