In the first major vote since Rep. Tom DeLay stepped down from the House GOP leadership, Republicans narrowly escaped an embarrassing defeat when nearly an hour of arm-twisting pushed through a bill designed to expand the nation's capacity to refine oil into gasoline.

To Democratic shouts of "Shame! Shame," House leaders held a five-minute vote open for 45 minutes as they worked to bring around balking moderate Republicans. The bill was fervently opposed by environmentalists and their Democratic and Republican allies, but under heavy pressure from House leaders, Rep. Wayne T. Gilchrest (R-Md.) switched his vote from no to yes, ensuring the bill's passage by a vote of 212 to 210.

And if rank-and-file Republicans wondered what role DeLay (R-Tex.) would play after his indictments last month on money-laundering and conspiracy charges, Friday's theatrics provided the answer. Even without a leadership title, DeLay made it clear that he will still wield power. Just as he did when he was part of the leadership, he was present for the whole vote, pressing dissenting Republicans, especially Rep. Roscoe G. Bartlett (R-Md.), who fidgeted with his voting card as DeLay pressed for his assent.

"It was a heck of a performance to turn this around," said Rep. Michael N. Castle (R-Del.), one of 13 Republicans who joined 196 Democrats and one independent to nearly defeat the Gasoline for America's Security -- or GAS -- Act. "The lesson was that nothing's changed."

"I saw DeLay come out of retirement," said Rep. John D. Dingell (D-Mich.) "I saw him twisting the arms of at least three of my colleagues. . . . I saw a lot of unhappy Republicans."

Kevin Madden, DeLay's spokesman, said his boss would continue to use his influence to promote the Republican agenda. "Leadership knew this was going to be a tough vote. Mr. DeLay worked to help leadership get the votes needed," he said. "Everybody knows Mr. DeLay is someone members often seek counsel from."

Supporters of the energy-industry-backed bill said it would help encourage construction of new refineries. The measure would provide subsidies to small refiners and make some federal land available for locating new refineries.

It also would cut the number of pollution-reducing blends of fuel that must be used around the country. The bill also aims to encourage the construction of more pipelines.

But as the voting drama played out, lawmakers said they also realized how crucial a victory would be. In his decade in power, DeLay was a master at orchestrating the passage of legislation or rounding up critical votes at the last minute while extending the period of the vote. And if the GAS Act had been defeated, DeLay would have been the story, Castle said.

For moderate Republicans aligned with environmentalists, the vote was all the more difficult because Senate passage is highly unlikely.

A half-hour after the vote was called, 15 Republicans had voted no, and the bill appeared headed for defeat. Then, after 38 minutes, Rep. C.W. Bill Young (R-Fla.) switched to yes. A minute later, Rep. Jim Gerlach (R-Pa.) switched to yes, after receiving assurances that a provision that calls on taxpayers to cover a refinery's legal bills if it is vindicated in court would be stripped out, according to Gerlach spokesman John Gentzel.

Moments later, Rep. Jeb Bradley (R-N.H.) approached the front of the House chamber to change his vote from yes to no, only to find himself ignored as he motioned for attention. House Minority Whip Steny H. Hoyer (D-Md.) jumped forward to wildly shout that a member wanted attention.

"You see him. You recognize him," Hoyer shouted, finally allowing Bradley to switch and momentarily give the opponents the upper hand. Then Gilchrest changed sides, and the vote was gaveled shut.

"The Democratic leadership wanted to embarrass Republicans politically instead of helping the energy needs of the Gulf Coast," said Ron Bonjean, a spokesman for House Speaker J. Dennis Hastert (R-Ill.).

Democrats were not about to let the political opportunity slip by.

"A vote that was supposed to take five minutes took more than nine times that long because the indicted Republican leader of the House of Representatives needed extra time to twist the arms necessary to pass a bill that is against the interests of the American people, against consumers, against taxpayers and against the environment," said Rep. Nancy Pelosi (D-Calif.).

After hurricanes Katrina and Rita, House Energy and Commerce Committee Chairman Joe Barton (R-Tex.) had hastily put the refinery legislation together without a hearing. Katrina and Rita knocked out much of the country's refining capacity, hampering production of gasoline and other oil products. Even before the hurricanes, supplies were tight and the ability to produce gasoline was not keeping pace with demand. The storms have elevated the price of gasoline. On the eve of the vote, Barton agreed to strip out a portion of the bill dealing with the Clean Air Act that had created the most controversy. The measure would have significantly altered the Clean Air Act by weakening some rules on pollution controls.

Environmentalists were most galled by Gilchrest's decisive vote. Half an hour before the vote, Gilchrest assured Friends of the Earth legislative director Sara Zdeb that he would oppose the bill.

"He went back on his word and was the defining vote to put it over the edge," Zdeb said.

Gilchrest aides declined to comment. The bill passed two months after President Bush signed legislation that supporters said would help expand domestic supplies. In a statement yesterday, Bush praised the House legislation.

Republicans highlighted parts of the bill designed to appeal most to constituents unhappy about high gas prices. The bill outlaws price gouging and calls on the Federal Trade Commission to set a definition. Democrats said the measure would do little and was designed to make the bill more palatable to constituents.

The bill could cost as much as $3.5 billion through 2015, according to a Congressional Budget Office estimate. But Congress would have to agree to spend the money in separate votes.

Staff writer Juliet Eilperin contributed to this report.