WASHINGTON — The move by OPEC on Wednesday to reduce oil production sharply undercuts President Biden’s effort to avoid an increase in gas prices ahead of the midterm elections, while setting back his push to constrain the oil revenue Russia is using to pay for its war in Ukraine.

It also exposes the failure of his fist-bump diplomacy over the summer with the crown prince of Saudi Arabia.

In both optics and substance, the move by OPEC and its allied oil producers underscored the challenges the United States faces in managing its foreign and economic policy at a time when the global economy is at risk of recession, and energy politics has emerged as a key component of the conflict in Ukraine.

The decision came during a meeting at OPEC’s Vienna headquarters that was attended by Russia’s deputy prime minister, who is under American sanctions. It followed a concerted but ultimately unsuccessful diplomatic effort by Washington to halt the oil production cut, a signal that Mr. Biden’s influence over his Gulf allies was far less than he had hoped.

And it demonstrated anew that, even in an era in which oil should be diminishing in importance as a source of energy, OPEC Plus acts in its own self-interests. In this case, sustaining the price per barrel has proved far more important to its members than making Russia pay a price for invading Ukraine.

The meeting of the OPEC Plus energy cartel, led by Saudi Arabia and Russia, brought together an array of foreign and economic issues that affect everything from domestic politics in the United States to the war in Ukraine.

For days, the White House sought to prevent the cut of two million barrels a day. It called on some of its closest Arab allies — starting with Saudi Arabia, where Mr. Biden visited in July, and met with the crown prince, Mohammed bin Salman, over the objections of human rights organizations and even some of his own advisers.

He took the risk, officials said at the time, to address a variety of national security concerns — but mostly to increase the supply of oil — even if it meant withstanding the critique that he was partaking in the rehabilitation of Prince Mohammed, who the C.I.A. concluded approved the assassination of the Washington Post journalist Jamal Khashoggi in 2018. During his campaign for the presidency, Mr. Biden had called Saudi Arabia a “pariah.”

The quiet understanding emerging from the trip was that Saudi Arabia would increase its production by about 750,000 barrels a day, and that the United Arab Emirates would follow suit with an additional 500,000, pushing down gas prices and worsening President Vladimir V. Putin’s ability to fund a war that was stretching much longer — and with much higher casualties — than Mr. Biden had expected.

But the production increases were fleeting. While Saudi Arabia boosted production significantly in July and August, it backed away from their promise to sustain those levels over the rest of 2022. Its leaders, and all of OPEC, worried that the specter of global recession was driving prices down, from $120 a barrel over the summer to below $80. Below that level, they fear, budgets have to be cut and social stability is threatened. So the Saudis decided they had to act.

The production cut announced Wednesday will reduce global daily production by about 2 percent, though some of that is a phantom reduction because the group’s members were already underproducing from their own goals. But its effect on prices may be greater, upward of 15 to 30 cents a gallon at the pump, experts estimated.

And for Mr. Biden, with midterm elections only a month away, the timing could not be worse.

But beyond the inflationary and political effect, the decision shatters any sense that the Arab allies were signed up to the cause of making Russia, also a member of the OPEC Plus group that met in Vienna, pay a price.

That should not have been a surprise. Iran is a member of the group, and it has grown closer to Russia in recent months, even selling it drones to prosecute the war in Ukraine.

And among those in attendance at the conference was Russia’s deputy prime minister, Alexander Novak, who is under U.S. sanctions for contributing to Russia’s aggression in Ukraine.

Mr. Novak is playing a central role in cooperating with other oil-producing countries — and seeking ways out of the effort by the United States and Europe to cap the price paid to Russia for its oil exports. At the news conference after the meeting in Vienna, he was conspicuously absent.

The effort to cap prices for Russian oil is now in jeopardy. The OPEC Plus decision helps Russia reap higher prices to offset the steep discounts it has been forced to give China and others, in return for their willingness to ignore the effort to isolate the country. In essence, the production cut will raise revenue for all the OPEC Plus members, Russia and Iran included.

In a statement from Jake Sullivan, the national security adviser, and Brian Deese, who heads the National Economic Council, the White House said Mr. Biden was “disappointed by the shortsighted decision by OPEC Plus to cut production quotas while the global economy is dealing with the continued negative impact of Putin’s invasion of Ukraine.” They said he would “consult Congress on additional tools and authorities to reduce OPEC’s control over energy prices.”

For their part, the Saudis were unapologetic.

“We would rather be pre-emptive than sorry,’’ Prince Abdulaziz bin Salman, the Saudi oil minister, told reporters about the effort to bolster prices. He said nothing about the quiet agreements with Washington in July.

The degree of anger and surprise at the White House was obvious: On Tuesday the press secretary, Karine Jean-Pierre, told reporters “we’re not considering new releases” from the nation’s Strategic Petroleum Reserve beyond what Mr. Biden had announced previously. On Wednesday morning, not 24 hours later, with the OPEC cut looming, a White House statement said “the president will continue to direct” new releases from the petroleum reserve “as appropriate to protect American consumers and promote energy security.”

“It’s clear that OPEC Plus is aligning with Russia with today’s announcement,” Ms. Jean-Pierre said Wednesday.

Officials did not say that Mr. Biden regretted the fist bump with Prince Mohammed, which represented his decision to move on from his stated goal of making Saudi Arabia pay a price for the grisly killing and dismemberment of Mr. Khashoggi. His discomfort during the trip was palpable — Mr. Biden never mentioned the dissident and former Washington Post columnist by name when he appeared with Prince Mohammed, and the prince remained silent when a reporter asked if he owed an apology to the Khashoggi family. (Mr. Biden later told reporter the murder was “outrageous” and said he confronted the prince privately, and “I made my view crystal clear.”)

Officials said at the time they had made major progress in ending the war in Yemen, which the Saudis had helped prosecute, and moved incrementally toward eventual Saudi recognition of Israel. Yet the Saudi decision to support the oil output cut by OPEC and its allies, and ignore the pressure from the United States, marked yet another step in the strategic distancing between the two historic partners.

If there is any lesson from Mr. Biden’s bitter experience, it is that the days are gone when American presidents could request favors from their Saudi allies and expect them to be carried out merely for the good of the relationship, or to ensure the continued American commitment to protecting the kingdom from foreign attacks.

Prince Mohammed has deliberately distanced himself from Washington, cultivating broader international relationships, notably with China and Russia. He has also made it clear that he does not view Saudi Arabia as a junior partner to the United States and that he is willing to shrug off any demands that he considers contrary to Saudi interests.

Since the start of the Biden administration, this dynamic has played itself out in the interactions between the crown prince and Mr. Biden. But it was never clearer than in recent months, when Mr. Biden and his aides argued that the time had come to reset the relationship. That’s what the fist bump symbolized. And the apparent Saudi agreement to increase oil output to help bring down global prices was part of the quid pro quo.

Wednesday’s cuts showed that the effects of that reset had been short-lived, or that the Saudis did not consider the benefits of helping the United States after Mr. Biden’s visit enough to continue the favor.

Some analysts of Gulf politics saw the move as a direct strike at Mr. Biden.

“It is definitely political. It has nothing to do with money,” said Cinzia Bianco, a Gulf research fellow at the European Council on Foreign Relations.

The Saudis, she said, had been disappointed by what they had received from the United States after Mr. Biden’s visit to the kingdom.

“So whenever it made political sense to backtrack and double down on a different strategy, they did,” she said.

Saudi analysts dismiss that characterization, echoing statements by officials from OPEC countries that the cuts were made for purely technical reasons.

“It is certainly not a hostile, anti-Biden act,” said Ali Shihabi, a Saudi analyst. “It has nothing to do with Biden. It is to keep the price in an acceptable band.”

Mr. Shihabi said that oil was so fundamental to the Saudi economy and to Prince Mohammed’s plans that ensuring that the commodity remained lucrative trumped other concerns.

“They are just trying to preserve their economic lifeline,” he said. “This is the lifeline in the kingdom, and everything depends on it in the kingdom.”

Other oil market watchers saw the new cuts as reflecting how global oil markets had been roiled in recent years, including by the Russian invasion of Ukraine and what appears to be an impending global recession.

Saudi Arabia has not criticized Russia’s invasion. And efforts by European countries to cut off Russian oil and gas to suck funds from Mr. Putin’s war machine have sent much of that oil to Asia, while the Europeans pursue other markets.

In the midst of that turmoil, the Saudis want to show that oil still matters and that they can drive the market.

“It is certainly a Saudi power move,” said Karen Young, a senior research scholar at the Center on Global Energy Policy at Columbia University. “They are establishing that they have the ability to make this market.”

David E. Sanger reported from Washington, and Ben Hubbard from Istanbul.