Hours after the European Union ended a temporary ban on exports of Ukrainian grain and other products to five member nations, three of them — Poland, Hungary and Slovakia — defied the bloc and said they would continue to bar Ukrainian grain from being sold within their borders.

As Ukraine, one of the world’s largest grain exporters, has struggled to ship its grain because of Russia’s invasion, the European Union has opened up to tariff-free food imports from the country, a move that had the unintended consequence of undercutting prices in several eastern E.U. member states. As part of a deal meant to protect those countries, the European Union allowed some grain to transit through them, but prohibited domestic sales.

Brussels’ decision to let that deal expire at midnight on Friday revived an issue that has threatened European Union unity on support for Ukraine. The Hungarian agriculture minister, Istvan Nagy, announced an extended ban that would include more products in a Facebook post early Saturday morning, saying that “we will protect the interests of the farmers.” Poland and Slovakia announced their bans on Friday.

Lawmakers in Bulgaria went in the other direction, agreeing on Thursday to resume imports of Ukrainian agricultural products, The Associated Press reported, saying the ban had cut into tax revenue.

The E.U. ban, which was implemented in May and expired at midnight on Friday, covered exports of wheat, maize, rapeseed, and sunflower seeds to Bulgaria, Hungary, Poland, Romania and Slovakia.

The ban was a response to concerns from those nations that a flood of cheap, tariff-free food imports from Ukraine was hurting their own farmers. All five had imposed tight restrictions on imports of Ukrainian grain before the E.U. ban came into effect, frustrating officials in Brussels and Kyiv.

The pushback against Ukrainian grain imports from Europe’s formerly communist eastern lands was a rare, and awkward, note of discord on the continent after remarkable European support for Ukraine’s war effort for more than a year after the full-scale invasion of February 2022.

They are the latest wrinkle in a long list of Ukraine’s grain woes, as fighting has raged around Ukraine’s agricultural heartland and after a huge explosion at the Kakhovka dam caused epic floods downstream and a punishing drought upstream.

This summer, Russia abandoned a deal that allowed Ukraine to safely ship tens of millions of tons or grain via the Black Sea despite the fighting, raising renewed concerns about a global food crisis. The Russian military has since specifically targeted grain warehouses and port infrastructure around the Black Sea. Dozens of facilities have been destroyed, Ukrainian officials have said, by Russian assault drones.

It was not immediately clear early Saturday how the rapid sequence of developments on Ukrainian agricultural exports to Europe would affect markets in Ukraine, Eastern Europe or beyond.

The European Commission, the E.U. executive arm, did not address the prospect of the new, unilateral bans in a brief statement on Friday. The statement said that market distortions in Ukraine’s five neighbors had “disappeared” as a result of the temporary ban, and that Ukraine was putting measures in place, including an export licensing system, to prevent new distortions.

On Friday, President Volodymyr Zelensky of Ukraine said in a post on X, formerly Twitter, that he said spoken with Ursula von der Leyen, the president of the European Commission, and thanked for “her keeping her word and upholding the rules of the single market.”

Mr. Zelensky also appeared to address the new bans indirectly in his nightly address on Friday, saying it was “important that European unity works on a bilateral level — with the neighbors.”

“Europe always wins when treaties work and promises are kept,” he added. “Well, if the neighbors’ decisions are not neighborly, Ukraine will respond civilly.”

Jeffrey Gettleman contributed reporting from Uman, Ukraine.