The Senate last night gave its all-but-final approval to a historic Alaska lands bill that would preserve a third of the state in pristine condition.

The compromise package, arrived at after four years of controversy, was approved 72 to 16 in the form of a substitute for the original bill. A final vote is scheduled today.

The measure still must run a tricky gauntlet to reach President Carter's desk before Congress adjourns in early October, since substantial and controversial differences with the House version remain. Sen. Paul Tsongas (D-Mass.), who steered the compromise in the Senate, said the measure has 95 percent chance of survival.

The lands bill, which Carter has called the environmental vote of the century, would place 106.2 million acres of virgin Alaska territory under varying categories of environmental protection. The dozens of separate parcels total an area larger than California and Maine combined, making the measure a modern equivalent of the legislation that opened the West to development.

This measure, however, provides what the conservationist Alaska Coalition has called "a last chance to do it right the first time." The prolonged debate has embodied most of the national conflict over energy needs, recreational and wildlife protection and land use in general.

Both Alaska senators opposed the measure, calling it an irresponsibile lockup of too much of the state's possible resources. Virginia's Sen. Harry F. Byrd Jr. (Ind.) was the only local senator to agree.

Yesterday's vote was preceded by a 63-to-25 decision to end a filibuster by Sen. Mike Gravel (D-Alaska). Gravel had thrown the Senate into turmoil two weeks ago by managing a filibuster under a time agreement.

Alaska Coalition chairman Charles Clusen called the cloture vote "a great victory . . . very, very important," but declined to predict the outcome of any cloture attempt on a future Gravel filibuster over whatever joint measure the Senate and House produce.

In what appeared to be a softening of the Carter administration's position, Interior Secretary Cecil D. Andrus told a news conference that the Senate measure was "a balanced relationship between energy and natural resources" and said Carter would sign it should it be the final version.

Carter and Andrus had led the fight for a strongly conservationist approach by using executive orders to protect most of the lands in question as monuments or wildlife refuges, thus prodding the Senate into action.

Tsongas said the Senate measure was "pretty much right down the middle" between the strongly environmentalist version that passed the House overwhelmingly last year and a Senate Energy Committee rewrite, much more open to resource development, on which debate began last month. Tsongas-backed amendments designed to green that version further bogged down in debate, and the whole issue was removed to closed-door negotiations among the major principals.

The package that emerged, which neared approval yesterday was "the best job we can accomplish under the circumstances," according to Sen. Ted Stevens (R-Alaska), who led the defense of the Senate Energy Committee approach. Alaska, he said, had achieved 5 1/2 of its seven major points, or "81 percent of the concessions we sought." He voted against the measure, he said, in order to come back next session and improve it further.

Tsongas said the outcome meets the top priorities of at least six different interest groups, none of which got everything it wanted. The senators' willingness to vote for cloture, he said, indicated "an absence of credible outcry" over the compromise.

The measure's major provisions:

An additional 56.4 million acres would be labeled wilderness and excluded from any oil, gas, mineral or other development.

Slightly less protection would be given to 49.8 million acres, with special development permits provided for six of nine major mineral areas, and timber cutting allowed in selected areas.

About 60 million federal acres would be conveyed to state control in accord with the 1958 statehood act.

Procedures for access to and across protected areas are spelled out, along with the requirements that cabins and traditional transportation methods in those areas must meet.

The lands involved include what have been called the "crown jewels of the continent": towering Mt. McKinley, the glaciers of the Brooks Range where caribou roam among grizzlies, wolves and polar bears; and the Wrangell-St. Elias parks in the southeast where the curly horned Dall sheep live.

One of the most controversial areas is the William O. Douglas National Wildlife Range in the northeast, where the world's largest caribou herd returns each year to calve. Environmentalists want that land protected totally, which the House bill would do, while the Tsongas compromise would permit five years of seismic exploration for a possible underground oil bonanza. Drilling would have to be authorized by Congress, however.

Other differences involve lumbering allowances in the southeastern Tongass National Forest, transit rights in the Gates of the Arctic National Park and in other public lands, and a "no more" provision to restrict future federal action to protect land.

Tsongas and Stevens agreed that the compromise leaves 300 million acres open to oil and gas development, or 95 percent of the probable best areas. Another 250 million acres would be open to mining, while 350 million acres, or 91 percent of the state, would be open to hunters, they said. m

The prospect exists that enviromentalists may move to kill the final measure, since existing monument and refuge designations from Carter and Andrus suit them fine. Clusen of the Alaska Coalition refused to be pinned down on the subject. "We're not going to be reckless. We very much want a bill," he said, "but we'll measure it when it come back from the House."