European Union leaders on Thursday reached an agreement to create a 50-billion-euro fund for Ukraine, bringing onboard Prime Minister Viktor Orban of Hungary, who had been the primary obstacle to a deal.

“All 27 leaders agreed on an additional €50 billion support package for Ukraine within the EU budget,” the president of the European Council, Charles Michel, said on social media just an hour into Thursday’s meeting. “This locks in steadfast, long-term, predictable funding,” he added. “EU is taking leadership & responsibility in support for Ukraine; we know what is at stake.”

What, if anything, Mr. Orban received in exchange for giving up his veto for the fund, valued at about $54 billion, was not immediately clear.

He had been demanding an annual chance to veto the disbursement of money to Ukraine, but that was rejected. Instead, E.U. leaders agreed to a regular review of the way the money was being spent, to assuage concerns about diversion or corruption, bloc officials said.

Under the agreement reached on Thursday, the European Commission, the bloc’s executive arm, will draft an annual report on how the Ukraine fund is being used. E.U. leaders will have a chance to debate its performance and raise any concerns about it.

Talks had been gridlocked, and the mood toward Mr. Orban, the closest ally in the European Union of the Russian president, Vladimir V. Putin, had been souring since Mr. Orban blocked the first attempt to introduce the fund for Ukraine in December.