The Trump administration and Republicans suffered a rare loss in their bid to roll back Obama-era energy regulations on Wednesday, as three GOP senators voted against revoking a rule to prevent methane leaks from oil and gas production.

Sen. John McCain cast a surprise vote against the measure, joining Democrats and fellow Republicans Lindsey Graham and Susan Collins to defeat the repeal attempt in a 49-51 vote.

McCain and Graham have been two of Trump's toughest critics among GOP lawmakers, primarily on matters of national security and allegations of alleged Russian interference in the 2016 election. On Tuesday, McCain criticized Trump for firing FBI Director James Comey, who was leading an investigation into whether Trump's associates coordinated with Russia to tip the election in the president's favor.

@SenJohnMcCain: Removal of Director Comey only confirms need for select cmte to investigate #Russia's interference in 2016 election

Republicans and the energy industry had sought to repeal the Bureau of Land Management regulation, which limits flaring of the potent greenhouse gas methane from oil and gas operations on federal land, through the Congressional Review Act.

Republicans have frequently employed the once little-used method to kill regulations passed in the final months of President Barack Obama's time in office.

In a statement, McCain expressed reservations about the rule, but said using the Congressional Review Act to repeal it would prevent BLM from creating a substantially similar rule. He said the public interest would be best served if the bureau instead revised the existing rule.

"Improving the control of methane emissions is an important public health and air quality issue," he said, adding, "I join the call for strong action to reduce pollution from venting, flaring and leaks associated with oil and gas production operations on public and Indian land."

In his first 100 days in office, President Donald Trump has set in motion the repeal of Obama's signature plan to cut greenhouse gas emissions from power plants, relaxed rules on coal waste, teed up a potential easing of automobile fuel efficiency standards and rescinded a host of other energy industry regulations and guidelines in a bid to increase fossil fuel production.

Industry groups such as the American Petroleum Institute say the BLM methane rule is unnecessary, because many drillers are already tackling the problem themselves and the regulation does nothing to help those efforts.

The methane rules have been challenged in court by a number of oil-producing states.

Scientists recently concluded that the oil and gas industry produced far more methane emissions than previously thought, but leaks from the sector did not drive the increase in overall emissions since 2007. That is because the industry has indeed reduced leaks.

But the scientists also concluded that while the industry got better at preventing methane leaks, increased production of oil and gas in the United States had offset that achievement.