As the war in Ukraine rages, an energy battle is spreading across Europe, with countries racing to replace Russian fossil fuels while Moscow cuts off gas supplies to some nations and threatens others with the same. 

The European Union vowed on Wednesday to continue to phase out purchases of Russian gas, support countries affected by Russian countermoves and speed up the switch to renewable energy in response to Russia’s decision to halt gas flows to Poland and Bulgaria

Russian energy giant Gazprom PJSC said it had not received payment in rubles for gas sales to Poland and Bulgaria, as required by a new decree by President Vladimir Putin. EU officials accused Moscow of using energy as a political weapon. The speaker of Russia’s State Duma, Vyacheslav Volodin, said on Wednesday that Moscow should expand the measures against other nations that it deems unfriendly. 

Two months into Russia’s war on Ukraine, EU countries are accelerating their efforts to replace Russian oil and gas. Steps by Germany and other national governments to switch suppliers are now proceeding rapidly, threatening to diminish Russia’s hitherto most lucrative source of foreign earnings. 

Germany and the EU have faced much criticism in recent weeks, including from Ukrainian President Volodymyr Zelensky, for their continued purchases of Russian oil and gas, which help fund Russia’s budget and its war effort. 

The EU is debating potential sanctions on Russian oil, including a full but phased-in embargo, but national measures by European countries are creating new facts on the ground faster than the negotiations in Brussels. 

Germany, Europe’s biggest economy, said on Tuesday it has all but overcome its need to import oil from Russia, thanks in part to an agreement with Poland over the use of ports and pipelines. Berlin said that phasing out Russian gas would take longer but that it is working on it.

For Moscow, the decision to throttle gas flows to Poland and Bulgaria is a high-risk gamble that could undermine one of main supports of Russia’s embattled economy. Oil and gas sales provide around 40% of the Russian government’s revenues. The EU is Russia’s main gas market.

“Gazprom’s announcement is another attempt by Russia to blackmail us with gas,” European Commission President Ursula von der Leyen

said on Wednesday. She said that Bulgaria and Poland are already receiving gas from EU neighbors and that discussions are ongoing on how to prevent significant disruptions. 

Analysts at energy consulting firm Rystad said that “Russia has fired the first shot back at the West,” wielding energy as a weapon. 

“Russia is trying to shatter the unity of our allies,” Mr. Zelensky’s chief of staff, Andriy Yermak, said on Telegram. 

The Kremlin on Wednesday denied it was using energy as a weapon and said it remains a reliable energy supplier. 

Many European countries have been scrambling to line up alternative gas supplies for next winter’s heating season, mainly liquefied natural gas imported from the U.S. and the Middle East, and gas piped in from Norway and North Africa. The EU aims to head into next winter with its gas storage facilities 80% full and to slash its purchases of Russian gas by two-thirds by the end of this year. 

The European Commission, the EU’s executive arm, is likely to make proposals next week for a sixth round of economic sanctions against Russia for its invasion of Ukraine, including an embargo on oil or other measures to cut Moscow’s revenues from oil sales. Several member states including Germany and Hungary have so far resisted a full embargo. But European demand for Russian oil is plummeting anyway.

Russia’s state oil company has had trouble finding buyers for oil in recent days. European refineries are already shifting away from Russian crude oil, even without sanctions. 

France’s TotalEnergies SE

has stopped buying Russian crude for its four oil refineries in France and Belgium. The company is still buying Russian crude under a supply contract for its refinery in Leuna, Germany, but a company official said the refinery would soon replace that with non-Russian oil brought in from the Polish port city of Gdansk. 

Russian energy giant Gazprom PJSC said on Wednesday that it had stopped supplies to Bulgaria and Poland.

Photo: maxim shipenkov/Shutterstock

Total is still buying some diesel from Russia under previous contracts but says it will end those purchases by the end of the year as the contracts expire.

Exxon Mobil Corp., which owns six refineries in continental Europe, said it has decided not to sign new contracts for Russian crude oil since the Feb. 24 invasion. The company was previously a big buyer of Russian crude.

European officials said they expect Moscow to cut gas supplies to more countries. Before the war in Ukraine, the EU sourced some 40% of its gas from Russia

Latvian Prime Minister Krišjānis Kariņš said in an interview that Russia’s moves are likely meant as warnings to the EU to slow down or stop its preparations for a full embargo on Russian oil.

“The question is who is more resilient?” Mr. Kariņš said, urging his EU colleagues not to be deterred. “The Ukrainians are paying with their lives, we are paying with higher energy prices.” 

Further gas stoppages by Russia would likely send fuel prices higher, analysts said, putting more pressure on the EU’s slowing economy and feeding into higher energy bills world-wide by prompting a race to find gas on international markets. In the U.S., natural-gas prices have doubled this year, in part because producers of LNG are shipping it to Europe at breakneck speed. 

Natural-gas prices in Europe are currently below their peak in March but well above their levels a year ago and remain a key source of inflationary pressure in European economies. Benchmark prices jumped 11% on Wednesday.

SHARE YOUR THOUGHTS

What do you think of Russia’s move to cut off gas? Weigh in below.

Mr. Putin demanded last month that countries deemed hostile to Moscow, including EU members, pay for gas in rubles. Gas contracts are usually denominated in dollars or euros. A subsequent Kremlin decree tweaked the order: Customers had to pay in euros or dollars to Russia’s Gazprombank, which would convert the money into rubles and send them on to Gazprom itself. The EU has said its sanctions don’t prevent companies from doing that.

Some European officials said Russia’s move against Poland and Bulgaria was likely not about payment modalities but was a warning aimed at all EU members that are sending weapons to Ukraine.

Germany on Tuesday announced that it would deliver antiaircraft cannon tanks to Ukraine, ditching its previous reluctance to send heavy weapons and joining a growing number of countries, led by the U.S., that are arming Ukraine’s defenders with artillery, armored vehicles and other powerful weaponry. 

Russia’s gas stoppage will have limited effect on Poland, which was already set to become independent of Russian gas by the end of this year. Still, Poland was due to receive at least a further 5 billion cubic meters in gas from Gazprom which likely won’t be delivered and will need to be replaced this summer, said James Huckstepp, European gas analyst at S&P Global Commodity Insights. Most of the gas will be pumped across the border from Germany, he added. 

The stoppage is a bigger problem for Bulgaria, which gets more than three quarters of its gas from Russia and has few quick or easy options to replace it. A new pipeline from Greece to Bulgaria to deliver gas from Azerbaijan has faced long delays and has yet to be completed, said Tom Marzec-Manser, head of gas analytics at ICIS. Using complex swap arrangements, Bulgaria could replace some of its Russian gas through an existing pipe to Greece, he said.

Bulgaria’s energy minister Alexander Nikolov said on Wednesday that the country has enough gas in storage for the coming month and is looking for alternative deliveries. 

“Because all trade and legal obligations are being observed, it is clear that at the moment the natural gas is being used more as a political and economic weapon in the current war,” Mr. Nikolov said.

Bulgaria’s ruling coalition has been split on the issue of sending weapons to Ukraine. A delegation led by Bulgaria’s prime minister, Kiril Petkov, is headed to Kyiv this week.

In Berlin, the government of Chancellor Olaf Scholz is accelerating investments in renewable energy and building LNG terminals. In the event of a full shutdown of Russian gas inflows, Germany would need to ration energy and suspend some industrial activity, according to analysts. The country’s leading economic think tanks said in a report earlier in April that Germany would enter a sharp recession if Russian energy deliveries are completely cut off. 

Russia’s move against Poland and Bulgaria is being watched closely in Italy, the second-largest buyer of Russian gas after Germany. Italy has already started to wean itself off Russian gas: the country’s imports so far in April are about half the level of the same month last year. 

Italian Prime Minister Mario Draghi and his foreign minister have crisscrossed Africa in the past month in search of deals to increase gas supplies from countries including Algeria, Mozambique and Angola.

Moscow has long used gas as a way to achieve its geopolitical aims. Last fall, Russia withheld deliveries to Europe from the short-term gas spot market despite a global shortage. It also kept the level of storage sites it controlled across the continent at low levels, helping to push prices to record highs. European lawmakers called for a probe into Russia’s manipulation of the market. Mr. Putin at the time dismissed criticism of the Kremlin’s energy tactics as “politically motivated blather.” 

—Laurence Norman, Eric Sylvers and Anna Hirtenstein contributed to this article.

Write to Georgi Kantchev at georgi.kantchev@wsj.com and Joe Wallace at joe.wallace@wsj.com