Russia pumps almost as much oil into the global market as it did before its invasion of Ukraine. With oil prices up, Moscow is also making more money.

Demand from some of the world’s largest economies has given Russian President Vladimir Putin the upper hand in the energy battle that shadows the war in Ukraine, and has confounded the West’s bid to cripple Russia’s economy with sanctions.

Sales are booming in Russia’s export market, the world’s largest in crude and refined fuels. And new trade arrangements have given Mr. Putin cover to use natural-gas exports as an economic weapon against Ukraine’s European allies. Before the war, Russia supplied Europe with 40% of its gas. It has since throttled flows through the Nord Stream pipeline to Germany and other conduits, driving prices higher and putting pressure on European households and businesses.

Oil revenue more than makes up the difference. “Russia is swimming in cash,” said Elina Ribakova, deputy chief economist at the Institute of International Finance. Moscow earned $97 billion from oil and gas sales through July this year, about $74 billion of that from oil, she said.

The country exported 7.4 million barrels of crude and products such as diesel and gasoline each day in July, according to the International Energy Agency, down only about 600,000 barrels a day since the start of the year.