The U.S. Postal Service and its two principal unions yesterday tentatively agreed on a three-year contract worth about $4.8 billion in extra pay and benefits, thus avoiding the possibility of a nationwide mail strike.

Announcement of the new pact, to replace the 1978 contract that expired at midnight Monday, came yesterday afternoon after a 30-hour bargaining session.

"This is the real thing," said federal mediator Nicholas Fidandis, in a reference to a settlement reported early yesterday morning that fell through two hours later. "We have a tentative agreement."

Asked if his union got what it wanted, President Morris (Moe) Biller of the American Postal Workers Union said: "We didn't . . . and that's a fact. However, we got enough for me to say it's a good contract, and I recommend approval."

The ratification process is expected to take a month.

Fidandis credited Postmaster General William F. Bolger, who entered the talks Monday night, with helping bring about the settlement with the APWU and the National Association of Letter Carriers, which represent 500,000 of the Postal Service's 600,000 organized workers.

According to Biller and NALC President Vincent R. Sombrotto, the highlights of the tentative agreement include:

A $900 basic wage increase over three years.

Productivity bonuses of $350 in each year of the contract.

An uncapped cost-of-living allowance identical to that in the old contract. This provision resulted in an extra $3,619 for each postal worker over the three years of the old contract.

A $150 "sweetener" bonus upon ratification of the contract.

Health benefits similar to those in the expired pact.

The Postal Service had sought a three-year-wage freeze; however, the tentative pact announced yesterday would mean about a 10 percent wage increase for postal employes, excluding benefits, over the next three years.

The average annual postal wage currently is $21,146, according to the Postal Service.

Bolger said that he did not think the new pact would drive up first-class mail rates beyond the 20-cent stamp the Postal Service has requested of the Postal Rate Commission. He said he thought the first-class rate could be held at 20 cents for a couple of years."

In separate negotiations, the National Rural Letter Carriers Association, which represents about 63,000 postal employes, also agreed yesterday to a tentative contract, the details of which were not known.

Representatives of a fourth group, the Mail Handlers Division of the Laborers' International Union, broke off their talks and said they would submit unresolved issues to binding arbitration in compliance with provisions of the 1970 Postal Reorganization Act. In the meantime, the union's 39,000 members will stay on the job.

The tentative settlement with the APWU and NALC came 16 hours after the midnight Monday expiration of the 1978 contract, which negotiators had extended on an hour-by-hour basis.

The session was marked by strike threats and confusion about what Postal Service officials later called a "misunderstanding" over oral contract language that had APWU and NALC leaders believing they had a tentative settlement at 2 a.m. yesterday.

Biller and Sombrotto quickly announced the persumed settlement, but when the terms were put in writing, they said they found "serious inconsistencies," which were not detailed between the oral and written language.

The discovery almost scuttled the negotiations, but at the urging of federal mediator Fidandis, the two men returned to the bargaining table.