The government and the air traffic controllers union reached a tentative contract agreement yesterday, ending the threat of a strike that could hve crippled the nation's commercial air service.

The settlement, which must be ratified by the union's membership, was reached yesterday during a 13-hour bargaining session involving Transportation Secretary Drew Lewis and Robert Poli, president of the 14,800-member Professional Air Traffic Controllers Organization. The union will hold a ratification vote on the new contract next week -- a process that could take up to one month to complete.

The new contract also is subject to congressional approval, which is expected. Lewis said yesterday that the package had been cleared by President Reagan, who through presidential assistant David Gergen called the settlement "fair."

A strike could have affected up to 75 percent of the nation's 14,000 daily scheduled flights. A work stoppage also have challenged federal statutes prohibiting strikes by federal employes -- a contest the Reagan administration and many members of Congress said they were determined to win.

The administration will face a similar labor challenge next month when three-year contracts expire with unions representing nearly 600,000 of the nation's postal workers.

Although government officials refused to characterize yesterday's agreement as a victory, administration officials said the tentative settlement was kept within the $40 million total cost the government first offered the union. The agreement did, however, involve a major reshuffling of the original government offer.

Lewis, who played a key role in the negotiations with the controllers union, called the tentative pact "fair and equitable." Poli agreed with that assessment, saying: "I'm pleased that we settled the contract. . . . I feel good about it."

Poli had sought a $770 million wage and benefits package from the Federal Aviation Administration; but the government, backed by congressional sentiment, balked at that request, saying that it would be inflationary. Although he did not get all of the money he wanted, Poli did get something else that he and many of his members said they needed.

The yet-to-be-ratified contract "for the first time establishes the principle that air traffic controllers are unique" among federal employes, Poli said.

Under the terms of the new agreement, which covers a 42-month term ending Jan. 15, 1985, controllers will receive:

A "responsibility" pay differential of time-and-a-half for the last four hours of a 40-hour workweek, or, as Lewis put it, "42 hours' pay for 40 hours' work." This is meant to be an extra payment for what the controllers believe is the extraordinary responsibility of safely guiding air traffice in and out of the nation's airports.

An increase in the nightime pay differential from 10 percent to 15 percent.

Premium pay without regard to the current $50,112 ceiling on Civil Service pay. Premiums are paid for night, Sunday and holiday work.

A retraining allowance of 14 weeks' salary for controllers with five consecutive years of service at the journeyman level who are forced to retire for medical reasons -- if they are not eligible for retirement or other job-related disability payments.

Lewis said the package represents a 6.6 percent average annual pay increase for the controllers in addition to the estimated 4.8 percent pay increase that all federal workers will receive this year. That means that the controllers, who had been seeking an immediate $10,000 raise, will get an average annual increase of $4,000, according to Lewis. Controllers earn an average of $34,000 annually.

The new contrct also gives controllers a voice on committees that make policy recommendations affecting the nation's air traffic control system. Lewis said that the government wants to benefit from the advice of the working controllers; but he cautioned that the FAA will retain management prerogatives.

Federal mediator Kenneth Moffett said that the two sides reached "an agreement in principle" between 3:30 and 4 yesterday morning, allowing Poli to call off a strike scheduled for 7 yesterday morning.

"At 3:30, I knew there would be no strike," said Moffett, who is also the chief mediator in the continuing baseball strike.