NEW YORK, JAN. 22 -- Sterling Drug Inc. and Eastman Kodak Co. agreed today to a $5.1 billion merger aimed at thwarting a hostile $4.6 billion bid for Sterling from F. Hoffmann-La Roche and Co.

Sterling and Kodak said that under a definitive merger agreement signed late this afternoon, Kodak would pay $89.50 a share for Sterling's roughly 57.5 million common shares outstanding.

The deal was announced after the close of the New York Stock Exchange. Sterling was down 12 cents to $78.75 a share.

Sterling is a major manufacturer of consumer products and drugs, including Bayer aspirin, Lysol cleaners and prescription medications. Kodak is the world's biggest photography company and also has major chemical operations.

Colby Chandler, Kodak's chairman and chief executive, said the merger was consistent with his company's earlier expressed strategy of entering the pharmaceutical industry.

"We expect the merger to generate a positive operating cash flow as early as two years and to contribute positively to Kodak's earnings perhaps as quickly as within three years," he said. "I can think of no other company which can bring to Sterling as many benefits as can Kodak."

Kodak, perhaps best known for its photographic film, has been involved in pharmaceutical research internally and with other companies since 1984. It formed a pharmaceuticals division in 1986 to centralize its research and business plans.

New York spokesmen for Hoffmann-La Roche, a pharmaceutical giant based in Switzerland, did not return telephone calls.

Sterling had rebuffed Hoffmann-La Roche's overtures since before the Swiss company launched its tender offer on Jan. 5.

Hoffmann-La Roche had sweetened its tender offer Wednesday to $81 a share from $76. It had made the latter offer on Monday after Sterling's board rejected the initial offer of $72 a share.