The Bell System and the Communications Workers of America reached tentative agreement on a new three-year contract last night, nearly three hours before the company's 701,000 unionized employes were set to strike.

The cost of the new pact will be $5 billion over three years -- about $1.7 billion more than the union's 1977-1980 agreement that expired last midnight.

In basic wages, the new contract would provide an average 34.4 percent increase, compounded at about 10.5 percent for each year of the agreement. Total compensation, including cost-of-living allowances and other benefits, would increase to about 35 percent over three years under the contract announced last night by CWA President Glenn E. Watts.

"I'm pleased, and quite frankly I'm surprised to be here," Watts said as he walked onto a platform in the Mayflower Hotel here to announce the tentative settlement. "We've achieved each of our major goals," said the union leader who, only hours before, was telling reporters that things were going badly and that a strike appeared certain.

Watts said the "breakthrough in negotiations that began June 4 occurred because of work by Federal Mediation and Conciliation Service officials led by Wayne Horvitz.

"I don't believe this settlement could have been achieved without them," Watts said.

The comment was tinged with irony. Horvitz and his staff work for the federal government that has been trying to put a 9.5 percent ceiling on annual wage increases.

But Watts insisted the settlement is "noninflationary" and does not violate voluntary wage guidelines administered by the Council on Wage and Price Stability. He said the new pact contains a number of increases -- improved pension and health benefits, for example -- that do not fall within the guidelines.

COWPS officials could not be reached for comment last night.

CWA, with 525,000 members in the Bell System, is the largest of three unions holding contracts with the telephone company. Two others, the International Brotherhood of Electrical Workers and the Telecommunications International Union, represent 176,000 Bell workers.

CWA is the "pattern-setter" in negotiations with Bell. The other unions, whose national contracts also were scheduled to expire last midnight, were expected to accept a similar tentative agreement.

Rank-and-file voting on the CWA agreement is expected to come in about a week, after all local union-company negotiations are completed, Watts said. He expressed confidence that the contract would be approved, especially by the Bell System's 97,000 telephone operators, who would be getting $390 per year above the basic wage increases in the new agreement.

The new pact also calls for reducing from 150 to 30 the number of times a month that operators job performance can be monitored. Reduction of the monitoring was a major demand of the operators and others who said the practice contributed to undue "job pressures."

Other new contract points included improvements in the cost-of-living allowance. The old contract returned 76 percent to 80 percent of pay lost to higher prices while the new pact would return 79 percent to 81 percent.

Improved dental, eye care and pension benefits are also in the new agreement.

The company had 138 million phones in service in 1979. It recorded a $5.7 billion income.