Jeff Bewkes turned HBO into a destination for prestige TV, with hits such as "Sex and the City," "Six Feet Under" and "The Sopranos."

Now that a judge has approved the purchase of Time Warner by AT&T, Bewkes could get what Tony Soprano never did — an unambiguously happy ending.

As CEO for the past decade, Bewkes focused Time Warner (TWX) on its entertainment, news and sports properties. He spun off AOL, Time Warner Cable and Time Inc., none of which has survived as an independent company.

He built what was left into an $85 billion acquisition target. And although the Justice Department could still appeal, the judge's blessing of the AT&T deal is a major step toward finalizing the deal — and cementing Bewkes' legacy.

Rise of subscription TV

Bewkes joined HBO in 1979, when pay cable networks were a novelty and mainly showed movies a couple of months after they were in theaters. HBO stands for Home Box Office, after all.

Bewkes worked up to chief financial officer and president before becoming CEO of the network in 1995.

During his tenure, HBO invested more in original programming and created water-cooler shows that gave people more reasons to subscribe. Among them were "Oz," "The Larry Sanders Show," "Entourage" and "Curb Your Enthusiasm."

They gave HBO a financial lift that continues to this day. HBO generated $6.3 billion in revenue and $2.2 billion in operating earnings last year, more than 20% of Time Warner's sales and profit.

Taking over at a humbled Time Warner

Bewkes took over as Time Warner CEO in 2008, replacing Richard Parsons at a time when the company was under pressure to slim down. Time Warner had recently come to a settlement with activist shareholder Carl Icahn, who was calling for a breakup.

Time Warner's merger with AOL, completed just before the dot-com bubble burst in 2000, had been a bust. AOL was slow to adapt to competition from cable companies offering cheaper and faster broadband, and subscribers left the service in droves.

Time Warner had lost almost $100 billion in 2002, mostly because of a writedown of AOL.

Parsons resisted pressure to make big changes, but other investors saw the merit in splitting up — and Bewkes wound up doing what Icahn asked for.

Under his watch, Time Warner completed a full separation of Time Warner Cable, and it spun off AOL and Time Inc., the venerable magazine company.

AOL was later acquired by Verizon (VZ). Time Warner Cable was bought by rival Charter Communications (CHTR) in 2016 and rebranded as Spectrum.

And Time Inc. was acquired by Meredith (MDP), the owner of Better Homes & Gardens, earlier this year. Meredith now wants to sell Time Inc.'s most storied magazines: Time, Fortune, Money and Sports Illustrated.

Related: War of the media moguls

"Bewkes was handed a mess from the AOL acquisition and was charged with cleaning that up," said Harold "Hal" Vogel, an analyst with Vogel Capital Management who has followed the media and entertainment industry since the 1970s.

"He followed the right path by simplifying the company and focusing it on its core entertainment assets," Vogel said. "He did a reasonably good job."

A focus on programming

Bewkes bulked up on the programming side — on both the small and big screens.

Beginning in 2011, the Turner networks TBS, TNT and TruTV won the rights to broadcast the NCAA men's college basketball tournament, also known as March Madness, alongside CBS. Turner also extended deals with the NBA and Major League Baseball.

And HBO, Bewkes' former home, kept churning out buzzworthy shows, including the hits "Game of Thrones," "Veep" and "Westworld."

"Bewkes kept the cable networks growing by focusing on sports and news. And HBO has always been near and dear to his heart," said Alan Gould, an analyst at Loop Capital who has followed Time Warner since before Time merged with Warner Communications in 1990.

CNN is a unit of Turner.

The Warner Bros. movie studio has cranked out blockbusters under Bewkes, including "The Dark Knight" and the Harry Potter franchise and, more recently, "The Lego Movie," "Wonder Woman" and "It."

And Bewkes successfully fended off an unsolicited takeover offer for Time Warner by Rupert Murdoch's 21st Century Fox (FOXA) that had fallen to about $60 billion by the time it was withdrawn in 2014. Two years later, Time Warner struck a deal with AT&T for $85 billion.

Bewkes is under contract until the end of 2020. He has said he'll serve as an adviser to AT&T for a short time after the deal closes, but will not stay on as an AT&T executive. Time Warner had no further comment.

Related: Verizon names new CEO to lead 5G push

New rivals

Bewkes, 66, stands to leave Time Warner with a big payout. Time Warner's total return, which includes dividends, has surged by nearly 260% since he took over as CEO. That's better than the S&P 500 during his tenure.

But they have slightly lagged total returns of big media rivals like Disney (DIS). And some would argue that Time Warner, like many other media companies, underestimated the growing clout of Netflix.

Related: Top Time Warner executives set for $180 million payout

In an interview with The New York Times in December 2010, Bewkes said that worrying about Netflix (NFLX) was like worrying about whether the Albanian army would take over the world.

"I don't think so," he concluded.

Netflix has more than twice the market value of Time Warner. It's catching up to HBO in worldwide subscribers.

And, along with Amazon and other tech companies, it has redefined how people consume entertainment — the industry earthquake that compelled AT&T and Time Warner to get together in Bewkes' final act.

Correction: An earlier version of this article incorrectly reported the final value of the Fox bid for Time Warner in 2014. This article also has been updated with Time Warner's total shareholder return.