WILTON, Conn. (AP) _ Richardson-Vicks Inc., four days after being dealt a setback in federal court as it tried to fight Unilever NV's hostile attempt at a takeover, found its ''white knight'' in Procter & Gamble Co., one of the largest consumer products manufacturers in the United States.

The companies on Tuesday announced agreement on a merger, worth at least $1.2 billion, in which Richardson-Vicks will become a wholly-owned subsidiary of Procter & Gamble.

Unilever today announced that it was terminating its tender offer and its court fight with Richardson-Vicks because of the agreement with Procter & Gamble.

P&G, based in Cincinnati, will pay $69 per share for all the Richardson- Vicks ' stock it is offered in a soon-to-be-commenced tender offer and a cash merger at the same price will follow, according to a statement issued jointly by the companies.

As part of the agreement, Richardson-Vicks and the Richardson family granted Procter & Gamble options to purchase virtually all of the stock each had bought in fighting Unilever.

Unilever said it was ''disappointed'' at its failure to merge with Richardson-Vicks, but said the $69 per share price ''exceeded the value of the business to Unilever.''

Unilever, based in the Netherlands, had offered $60 per share if Richardson-Vicks' directors approved and $48 if they didn't. Richardson-Vicks twice rejected the company's overtures.

As of Sept. 24, Richardson-Vicks had 17.7 million shares outstanding, making the deal worth $1.2 billion. However, Procter & Gamble also has been granted the option of purchasing 4.4 million shares from Richardson-Vic ks; should the option be exercised, it would cost Procter & Gamble another $303 million.

A statement released by the companies said Procter & Gamble also had separately been granted options to buy all 6.3 million of the shares held by the 23-member Richardson family and trusts under its control.

Richardson-Vicks had purchased about 5 million of the 7 million shares it intended to buy. Together, the stock purchases and options, if exercised by P& G, would represent 48.9 percent of the then-outstanding shares of Richardson- Vicks' stock - meaning that in a worst-case scenario P&G need only be offered about 2 percent of the company's outstanding shares to gain majority control.

The statement said P&G also has been granted options, exercisable under certain curcumstances, to buy additional shares of Richardson-Vicks' stock from the company and has been given the right to buy Richardson-Vicks' profitable Oil of Olay line.

Richardson-Vicks' chairman, Stuart Smith Richardson, said his company's ''board of directors fought a hard battle to preserve the interests of all the shareholders. This has now been done.''

John S. Scott, the company's president, said P&G was ''the ideal merger partner for Richardson-Vicks because of our common dedication to the quality of our products and treatment of our employees.''

John S. Smale, P&G's president and chief executive officer, said the merger was ''an important step for Procter & Gamble. We are merging two fine companies with similar cultures and commitments to our customers.''

In its fiscal year that ended June 30, Procter & Gamble had net income of $635 million on sales of $13.6 billion; the earnings were down from the previous year's $890 million, acheived on sales of $12.9 billion. The company had about 62,000 employees.

P&G is one of the nation's largest manuafacturers of laundry and cleaning, personal care and food products. Among its well-known brand names are Ivory soap, Tide laundry detergent, Comet cleanser, Crest toothpaste, Prell and Head and Shoulders shampoo, Charmin bathroom tissue, Crisco cooking fat and Folger coffee. It recently has been dogged, however, by rumors that it promotes satanism.

Richardson-Vicks, which Smale said will remain in its Wilton headquarters, reported net income of $72.2 million on sales of $1.2 billion in its fiscal year ended June 30. Among its brand names are Oil of Olay, Nyquil and Vicks cold remedies and Clearasil acne medication. The company employs about 10,700 people, 500 of whom work at the Wilton headquarters.

Richardson-Vicks reportedly had been considering at least three friendly takeover bids. Besides Procter & Gamble, others mentioned Tuesday were Colgate-Palmolive Co. and Pfizer Inc., both of New York. They made their bids Monday at a special meeting in New York at which Richardson-Vicks' board of directors sought a way to escape Unilever's takeover attempt, The New York Times reported.

Unilever's offer, made through its U.S. arm, would have been worth about $1.1 billion at $60 per share and $850 million at $48 per share, both based on 17.7 million outstanding shares.

The agreement with Procter & Gamble came two days after Richardson-Vicks announced that a federal judge had ordered it not to begin issuing a special series of preferred stock with super voting rights - one of several elements of the company's anti-Unilever stance.