BRUSSELS, May 30 (Reuters) - European Union leaders agreed in principle on Monday to cut 90% of oil imports from Russia by the end of this year, resolving adeadlock with Hungary over the bloc's toughest sanction yet on Moscow since the invasion of Ukraine three months ago.

Diplomats said the agreement would clear the way for other elements of a sixth package of EU sanctions on Russia to take effect, including cutting Russia's biggest bank, Sberbank (SBMX.MM), from the SWIFT messaging system.

"Agreement to ban export of Russian oil to the EU," said European Council President Charles Michel in a tweet at the end of the first day of a two-day summit of the bloc's 27 leaders.

"This immediately covers more than 2/3 of oil imports from Russia, cutting a huge source of financing for its war machine. Maximum pressure on Russia to end the war," he said.

Two thirds of the Russian oil imported by the EU comes via tanker and one third by the Druzhba pipeline. The embargo on seaborne oil imports would therefore apply to 2/3 of all oil imported from Russia.

The embargo would encompass 90% of all imports from Russia once Poland and Germany, which are also connected to the pipeline, stop buying it by the end of the year.

The remaining 10% will be temporarily exempt from the embargo so that landlocked Hungary, which was the main holdout for a deal, along with Slovakia and the Czech Republic, which are all connected to the southern leg of the pipeline, has access which it cannot easily replace.

Budapest also appeared to have won reassurances from other leaders that emergency measures would apply "in case of sudden interruptions of supply" following concerns raised by Prime Minister Viktor Orban about risks posed to the Russian oil pipeline that runs through Ukraine to Hungary.

The ban on oil imports to EU countries will apply to Russian crude that is delivered by shipments.

It was not immediately clear how member states that receive oil from tankers would be compensated for the higher cost compared with those that will keep the pipelines open.