Paramount Pictures on Sunday agreed to buy independent film studio DreamWorks SKG Inc. for nearly $1 billion in cash in a deal designed to help both companies reverse their troubled fortunes.

The sale marks the end of an 11-year dream for Hollywood moguls Steven Spielberg, Jeffrey Katzenberg and David Geffen, who had ambitious goals for DreamWorks that once included television, music, films and the Internet.

And the acquisition is seen as a critical gambit for Paramount, which has been under orders from parent company Viacom Inc. to improve its movies and earnings.

Paramount will pay $775 million in cash and assume $825 million in debt and other obligations, the company said.

The studio will finance the deal by immediately selling the DreamWorks film library, which Paramount values at $850 million to $1 billion. The company said it expects to have a deal within weeks.

Paramount will retain distribution rights to the 59 library titles, which includes such hits as "American Beauty" and "Gladiator."

The deal does not include DreamWorks Animation SKG Inc., which went public last year. Paramount does gain the right to distribute the animated studio's lucrative films for the next seven years, including the profitable "Shrek" franchise.

Paramount put its offer together just last week, after DreamWorks had been discussing terms with NBC Universal for nine months.