The Senate Judiciary Committee yesterday narrowly approved a bill restricting the right of the 18 largest oil companies to acquire other large companies, particularly outside the energy field.

The 8-to-7 vote was a victory for Sen. Edward M. Kennedy (D-Mass.), chairman of Judiciary and a candidate for next year's Democratic presidential nomination, who has been a leading sponsor of the bill.

But the victory seemed likely to be more show than substance, since even supporters said the bill has at best an uncertain future on the Senate Floor, while the House has taken no action on the subject.

The bill in part reflects senatorial indignation at this year's rising oil prices and record oil company profits. Its basic purpose is to force the companies to use more of their resources for energy exploration, and less for diversification into other sectors of the economy. In recent years almost all the major oil companies have bought up large companies in energy and other fields. Their nonenergy acquisitions have ranged from copper mines to department store chains to newspapers.

The bill would prevent oil company purchases of nonenergy-related firms with assets of $50 million or more. It also would bar acquisition of energy-related firms with assets of $100 million or more.

An exception to the ban would be transactions that would enhance competition or materially "increase or substantially promote energy exploration, extraction, production or conversion."

Under the proposal, judgments about oil company acquistions would be made by the attorney general, under the Clayton Act, which deals with mergers and which the legislation would amend.

At the close of a stormy, 2 1/2-hour Hill hearing, committee Democrats, with the exception of Howell Heflin (Ala.), approved the bill after a series of amendments were considered.

The most controversial was a proposal by Sen. Bob Dole (R-Kan.) that would have prevented the acquisition of a large firm by an oil company unless its energy investments in the previous year exceeded company profits. The amendment was defeated, 8 to 7.

The bill's supporters used the hearing and the legislation as a forum for venting their frustration with oil company profits and lobbying techniques.

"I'd be willing to go this way [vote for the bill] just to stick it in their left ear," said Sen. Joseph R. Biden Jr. (D-Del.), who complained of contradictory statements by oil company witnesses before the Judiciary and Finance committees.

The Finance Committee considered a oil "windfall profits" tax, which is now before the full Senate.

Biden said the oil firms told the Judiciary Committee that the bill, in hindering diversification, would prevent them from making deals they need for survival, while at the same time they told the Finance Committee of their need to retain capital for development of new oil sources.

Sen. Birch Bayh (D-Ind.) said yesterday's vote was a "signal to the American people that we are willing to tackle the big boys."

On the other hand, some Republicans on the Judiciary Committee argued, as the oil companies have, that the bill would hurt the oil industry's effort to raise funds for energy development.

The American Petroleum Institute, the major oil lobbying group, said the committee vote could "result in less oil production and could also inhibit the development of alternative and synthetic fuels."

"All this could occur," the API said, "because a ban on major mergers and acquisitions by large oil companies would inhibit the diversification through which companies gain stability of income and permit high-risk investment in the search for oil and natural gas."

Oil company spokesmen also argue that the legislation would hamper U.S. energy companies in explorations abroad, a concern also expressed by representatives of Canada, Norway and Britain.

However, since those complaints were made through the State Department, the bill has been amended so that it would apply to foreign transactions only in accordance with international law.

Meanwhile, the Senate moved slowly toward its first showdown -- probably early next week -- over whether to stiffen the windfall profits tax recommended by the finance panel.

A proposal by Sen. Dale Bumpers (D-Ark.) would substitute the House passed windfall profits tax for the Senate committee bill, thereby doubling estimated revenue from the tax from $138 billion to $277 billion over the next decade.

The Senate has twice rejected moves to weaken the committee bill but has not yet voted on any of the numerous amendments to strengthen it. A dwindling of Senate ranks in advance of the Thanksgiving recess prevented any votes on the issue yesterday.

Kennedy used the Bumpers proposal as a political cudgel against Carter, taunting the president for not actively championing it even though the House bill is more in line with the administration's proposal than is the Senate version.

Specifically, Kennedy supported Bumpers' proposal to use some of the tax proceeds for rollback of a Social Security tax increase scheduled for 1981, a move opposed by the administration.