BRUSSELS (AP) — In the most significant effort yet to punish Russia for its war in Ukraine, the European Union agreed to ban the overwhelming majority of Russian oil imports after tense negotiations that tested how far the bloc is willing to go to ostracize Moscow.

From the moment Russia invaded on Feb. 24, the West has sought to make Moscow pay economically for its war. But targeting the lucrative energy sector was seen as a last resort in Europe and has proved hardest since the bloc relies on the country for 25% of its oil and 40% of its natural gas. European countries that are even more heavily dependent on Russia have been especially reluctant to act.

In a move unthinkable just months ago, EU leaders agreed late Monday to cut around 90% of all Russian oil imports over the next six months.

Belgian Prime Minister Alexander De Croo called the embargo a “big step forward” on Tuesday morning and Irish Prime Minister Micheal Martin hailed it as “a watershed moment.” But both leaders cautioned that Europe would need time to adjust to the impact — and any further bans on Russian energy could only come slowly, if at all.

The deputy head of Russia’s Security Council said Tuesday that energy sanctions against the country were intended to hurt ordinary Russians by making it harder for Moscow to fund social programs.

“They hate us all! The basis for these decisions is hatred for Russia, for Russians and for all its inhabitants,” Dmitry Medvedev, who is also a former president and prime minister, wrote on the Telegram messaging app.

Mikhail Ulyanov, Russia’s permanent representative to international organizations in Vienna, appeared to shrug the move off, though, saying Moscow would find other buyers.

Still, analyst Simone Tagliapietra said Russia would likely have to sell its oil at a substantial discount. Tagliapietra, an energy expert and research fellow at the Brussels-based think tank Bruegel, called the embargo “a major blow.”

Matteo Villa, an analyst at the ISPI think tank in Milan, agreed that Russia would take a pretty significant hit now — but cautioned that the move could eventually backfire.

“The risk is that the price of oil in general goes up because of the European sanctions. And if the price goes up a lot, the risk is that Russia starts to earn more, and Europe loses the bet,” he said. Ideally, the EU would agree how much Russian oil to purchase each month to ensure the maximum pain, Villa said, but that would require constant negotiations that are not realistic given how the bloc works.

Russia has also not shied away from withholding its energy supplies, despite the economic damage it could suffer as a result. Russian energy giant Gazprom said it cut natural gas supplies to Dutch trader GasTerra on Tuesday — a move announced before the embargo was agreed. It already turned the taps off to Bulgaria, Poland and Finland, and is considering doing the same to Denmark.

GasTerra said homes would not be hit as it had bought gas elsewhere in anticipation of a shutoff.

Talks at EU headquarters in Brussels were set Tuesday to focus on ways to end the trading bloc’s dependence on Russian energy, by diversifying supplies and speeding up the transition to renewable sources and away, as much as possible given soaring energy costs, from fossil fuels.

Leaders are also expected to discuss how to help Ukraine export millions of tons of grain trapped inside the country as a global food crisis grows.

They are also calling on Russia to halt its attacks on transport infrastructure in Ukraine and lift its blockade of Black Sea ports so that food can be shipped. Ukrainian President Volodymyr Zelenskyy has said Russia has prevented the export of 22 million tons of grain, much of it meant for people across the Middle East and Africa. He accused Moscow of “deliberately creating this problem.”

In other developments:

— Russian forces have seized around half of a key city in eastern Ukraine, according to the mayor. Analysts have painted the battle for Sievierodonetsk as part of a race against time for the Kremlin: The city is key to Russian efforts to quickly complete the capture of the eastern industrial region of the Donbas before more Western arms arrive to bolster Ukraine’s defense.

— A court in Ukraine convicted two Russian soldiers on Tuesday of war crimes for the shelling of civilian buildings. It sentenced both to 11 1/2 years in prison, concluding the country’s second war crime trial held since the Russian invasion.

The EU oil embargo, tied up in a new package of sanctions that will also target Russia’s biggest bank and state media outlets accused of spreading propaganda, covers crude oil and petroleum products but has an exception for oil delivered by pipeline.

That exception was demanded by Hungarian Prime minister Viktor Orban, who made it clear that he could only support the new sanctions if his country’s oil supply security was guaranteed. Hungary gets more than 60% of its oil from Russia, much of it through the Soviet-era Druzhba pipeline.

The EU estimated that would mean around 90% of Russian oil is banned by the end of the year. That figure includes a ban on all Russian oil delivered by sea — which accounts for two-thirds of the EU’s imports from Russia — plus a decision by Germany and Poland to stop using oil from the northern branch of the Druzhba pipeline.

The sanctions package must still be finalized in coming days — and the leaders said the exemption for crude delivered by pipeline will be reviewed “as soon as possible,” though they did not specify when.

The compromise laid bare the increasing difficulty of reaching consensus among EU leaders when important national interests are in play — and the ways in which Hungary has emerged as thorn in the bloc’s side.

But despite the struggles, the sanctions package — the sixth targeting Russia’s invasion of Ukraine — was agreed in about a month, quite quickly for 27 countries with very different national interests.

Agreeing on another round of measures is likely to prove much tougher — especially because next on the docket is whether to target natural gas, which is much harder to cut off. That’s because it represents a larger percentage of Europe’s energy mix.

___

Associated Press journalists Yuras Karmanau in Lviv, Ukraine, Mike Corder in The Hague, Netherlands, Colleen Barry in Milan, Italy, and Derek Gatopoulos in Athens contributed to this report.

___

Follow the AP’s coverage of the war at https://apnews.com/hub/russia-ukraine