A bill that would bar mergers among the nation's largest oil companies for 18 months while the Federal Trade Commission and Congress study their impact was voted out of a House subcommittee yesterday with strong bipartisan support.

Only two members--both Democrats from oil-producing states--opposed the measure. The bill would place the moratorium on acquisitions by the top 20 oil companies of more than 5 percent of the stock or more than $1 billion worth of crude oil of any of the top 40 companies.

The sweeping proposal is a response to Mobil's attempt to take over a smaller oil company and predictions that Mobil's success would trigger a wave of mergers.

A plan to rush the proposal through the Senate and the House of Representatives yesterday apparently fell apart. Supporters had planned to offer the moratorium as a rider to a noncontroversial, unrelated bill, but no appropriate vehicle could be found. Another complication was a newspaper report about the plan, which put lobbyists and members of Congress from oil-producing states on alert.

In the meantime, however, the House Energy and Commerce subcommittee on fossil and synthetic fuels was taking the first step toward advancing the bill in a more traditional manner under which it could not pass until the next session of Congress.

"The real question is: What is in the ultimate long-run good of the people of the United States?" said Rep. Clarence J. Brown (R-Ohio). A wave of mergers among oil companies threatens to sweep by so rapidly that the industry would be transformed before anyone had a chance to determine the answer to this question, he said. He also indicated that some oil comanies want the merger wave slowed because of fears of takeovers, perhaps by foreign government-owned oil enterprises.

Brown is the chief sponsor of the legislation in the House of Representatives. The bill is also supported by subcommittee chairman Philip R. Sharp (D-Ind.). "If we don't get a moratorium" in this session, "We sure want to send the oil companies a signal," said Sharp. Sens. Robert Packwood (R-Ore.) and Howard Cannon (D-Nev.), the chairman and ranking Democrat on the Senate Commerce Committee, support a similar bill.

While the subcommittee was approving the moratorium, its supporters still held out hope that the proposal might get through both houses of Congress yesterday.