The compromise $227 billion crude oil tax finally passed Congress yesterday as the Senate, rejecting one last oil-state effort to sidetrack it, sent it on to President Carter by a vote of 66 to 31.

Although weaker than the tax proposed by the president nearly a year ago, it gives him the centerpiece of his energy program and hands him a major election-year legislative victory.

But even as Carter was thanking Senate supporters of the bill, a House subcommittee, rebelling at rising energy prices, moved to thwart Carter's additional plan to impose an oil import fee that would raise gasoline prices by 10 cents a gallon.

Carter responded immediately by vowing through a spokesman, to veto any such legislation.

The oil tax, the largest ever imposed on a single industry, seeks to reclaim half of the proceeds that oil producers expect to reap from Carter's gradual lifting of controls on domestic crude oil prices -- $227 billion for the goverment during the 1980s.

It also includes two tax sweeteners that have nothing to do with oil:

A tax exemption of up to $200 a year for individuals, or $400 on a joint return, for interest and dividends in 1981 and 1982 -- a broadening and doubling of the present $100 per person, or $200 per couple, exemption for dividends alone.

Repeal of a scheduled capital gains tax increase on profits from the sale of inherited property.

In addition, the oil tax bill reserves 60 percent of the government's share of the decontrol "windfall," about $137 billion, for tax cuts or deficit reduction during the next 10 years. The rest is to be used for transportation programs, energy development and fuel cost relief for low-income families.

The bill passed yesterday and sent to Carter for signing into law was a compromise between a House-passed measure similar to what Carter wanted and a scaled-down version approved by the Senate. In terms of revenues, the compromise split the difference between the two.

Before approving the compromise, the Senate rejected, 61 to 35, an effort by some oil-state and Republican senators to send the bill back to the Senate Finance Committee for hearings on its impact on production, independent producers and royalty holders.

Sen. Bob Dole (R-Kan.) said the oil tax would impose a crushing financial burden on small producers and thousands of small-scale royalty holders, while crippling the oil industry's ability to expand domestic production.

But Senate Finance Committee Chairman Russell B. Long (D-La.), arguing that the Carter administration would reimpose controls if the bill were sidetracked, said he doubted that anyone who paid the tax would be financially pinched enough to "apply for welfare."

Earlier Sen. Henry L. Bellmon (R-Okla.), who had led a week-long talkathon against the compromise, abandoned his proposal to send the bill to the Appropriations Committee for a review of its budget implications. As he gave up, Bellmon complained that "once Congress gets hooked on these revenues, it is virtually certain [the tax] will never be repealed."

The tax, levied at different rates on different categories of oil, with major oil companies paying $205 billion and independent producers $22.5 billion, is to be phased out toward the end of the decade. It is to take effect retroactively on March 1.

Calling the congressional action "good news for the country and . . . for the whole world," Carter called reporters to the Oval Office to hear him telephone his congratulations to Long and Senate Majority Leader Robert C. Byrd (D-W.Va.).

"You can leave the ribbons off this one in order to get it on down here," Carter told them.

But the glow faded at news that the House Commerce energy subcommittee voted to deny the Energy Department the funds that it needs to carry out the administration's announced plan to drive up gasoline prices by a $10.3 billion oil import fee.

"We're reflecting the anger of the driving public . . ." said Rep. Anthony Moffett (D-Conn.), a leader of the liberal Democratic and conservative Republican coalition seeking to force Carter to withhold the fee.

Administration supporters responded that the move could result in higher heating oil and diesel fuel costs if the administration is prevented from applying the increased cost only to gasoline. While Carter does not need congressional approval to impose the fee, it can thwart implementation in this and probably other ways.

All Washington area senators voted for the oil tax except Sen. Harry E. Byrd Jr. (Ind.-Va.).