Captain Underpants is joining Comcast.

The nation's cable giant agreed to acquire the money-losing studio DreamWorks Animation SKG for $3.8 billion, or $41 a share - a 51 percent premium to DreamWorks' closing share price on Tuesday, before news leaked of the deal.

The multibillion-dollar deal for the studio that created the hugely popular Shrek franchise and the animated feature Captain Underpants bolsters Comcast's NBCUniversal unit and deepens its offerings in family entertainment.

Justice Department antitrust officials will review the deal, as will regulators in other countries. Comcast and DreamWorks expect the deal to close this year.

The deal gives NBCUniversal the ability to make more animated features and commercialize DreamWorks' library of works in theme parks, TV shows, and even toys, Jeff Shell, chairman of the Universal Filmed Entertainment Group, said Thursday.

He and analysts compared the deal to how Walt Disney Co. grew its content by buying Pixar, creator of Finding Nemo, a decade ago and snagging Lucasfilm, owner of Star Wars, in 2012.

"If you look at the tremendous [entertainment] machine that Disney has created . . . we had some of the pieces," Shell said. "What we didn't have is scale in consumer products, and we didn't have enough intellectual property in the animated space."

DreamWorks properties provide that with such animated favorites as The Croods, How to Train Your Dragon, Madagascar, and Trolls. Captain Underpants is planned for a 2017 release.

In the midst of a turnaround, DreamWorks has scaled back film releases to one or two a year and diversified into TV production for Netflix and the Chinese movie market.

DreamWorks will now merge with NBCUniversal's relatively new Illumination Entertainment animation studio, maker of Minions and Despicable Me.

Shell expects the merged entity to release three or four animated films a year.

A former Comcast executive, he also expects to see more synergies, with DreamWorks characters appearing in the Universal theme parks - think Shrek - and DreamWorks-produced TV shows based on Universal's intellectual property, such as the cars and characters in The Fast and the Furious movies.

Besides studio production, Comcast gains control over the DreamWorks library of 32 animated films and 400 classic TV titles or characters, among them Lassie and Casper the Friendly Ghost.

The money that Comcast pays for DreamWorks will be a fraction of the $45 billion deal that Comcast pitched for Time Warner Cable, which regulators scotched last year.

And DreamWorks will be just a swell in the Comcast ocean, totaling about 1.2 percent of the cable giant's revenues.

But the $3.8 billion price is high for what has been a troubled independent Hollywood studio.

"It's a very good premium," said Tony Wible, an analyst with Drexel Hamilton. "But they are buying into a future with DreamWorks."

Geetha Ranganathan, an analyst with Bloomberg Intelligence, said the premium could be justified because of the profitability of animated films.

"DreamWorks has bounced back," she said. "They had some off years, but they diversified away from films."

About 30 percent of DreamWorks' revenues is derived from entertainment streams outside of the movie box office, Ranganathan said.

DreamWorks lost $54.8 million in 2015 on $915 million in revenues after losing $309.6 million on $684.6 million in 2014.

Shell had talked with DreamWorks chief executive Jeffrey Katzenberg for about two years on how the two companies could work together.

Shell said deal negotiations advanced quickly after Comcast chief executive Brian Roberts called Katzenberg, 65, about two weeks ago.

Katzenberg owns 60 percent voting control of DreamWorks and agreed to the deal in a written consent, according to the companies.

As recently as February 2013, the DreamWorks stock dropped as low as $16.16 a share.

On Tuesday, before reports surfaced of talks between the two companies, DreamWorks stock closed at $27.12. On Thursday it closed at $39.95.

A former Disney executive, Katzenberg will make about $405 million selling his DreamWorks shares, based on the company's filing with the Securities and Exchange Commission.

Katzenberg will be retained as a consultant to NBCUniversal and will chair a DreamWorks venture, AwesomenessTV, which is producing short video clips for streaming. Hearst Corp. and Verizon are also partners in the venture.

"Having spent the past two decades working together with our team to build DreamWorks Animation into one of the world's most beloved brands, I am proud to say that NBCUniversal is the perfect home for our company," Katzenberg said in a statement. It's "a home that will embrace the legacy of our storytelling and grow our businesses to their fullest potential."