With the endpoint near on a crucial deal that allowed Ukrainian grain shipments through a Russian naval blockade, the United Nations said it was racing to bridge differences to extend the agreement, which has helped alleviate food shortages and limit price increases.

Russia and Ukraine have been at odds over how long to extend the deal, which is set to expire late Saturday. Moscow has said it would agree to an extension of only 60 days because its own food and fertilizer exports were being hampered by sanctions. Ukraine, Turkey and the United Nations have pushed for a 120-day renewal, in line with the initial agreement in July and with a subsequent extension in November.

The deal allows ships carrying grain and fertilizer from Ukraine safe passage to Turkish waters, where they are inspected by a joint team of Turkish, U.N., Ukrainian and Russian officials.

It was a rare diplomatic breakthrough between Ukraine and Russia since Russia’s invasion in February 2022, but Russia has held the deal hostage at various points during the war. In late October, the Kremlin abruptly suspended its participation in the agreement after an attack on its warships in the Black Sea port of Sevastopol, but it rejoined a few days later.

At the time, President Vladimir V. Putin of Russia said in televised remarks, “Russia retains the right to leave these agreements if these guarantees from Ukraine are violated.”

The United Nations is “doing everything possible” to ensure the continuation of the Black Sea Grain Initiative, which it brokered with Turkey, Martin Griffiths, the U.N.’s humanitarian chief, told the Security Council on Friday, the eve of the deal’s expiration.

“Conversations are being had in various permutations at various levels,” the U.N. spokesman, Stéphane Dujarric, said Friday.

The Black Sea has been a flashpoint of strategic importance where Russia’s powerful naval fleet runs up against three members of the North Atlantic Treaty Organization — Turkey, Romania and Bulgaria — that share the coast. This week, a U.S. surveillance drone was brought down after being struck by a Russian fighter jet, U.S. officials said. That was the first known physical contact between the Russian and American militaries since the war began.

On Thursday, Ukraine’s military said it had observed a sharp increase in the number of Russian naval vessels in the Black Sea to 21, from 13 a day earlier.

Since the grain deal took effect last summer, more than 23 million tons of grain have been exported through the corridor, stabilizing food prices and alleviating shortages, according to the United Nations.

Ukraine is a leading exporter of wheat, barley, corn and sunflower, but its shipments plummeted after the war began. Exports from Russia, another major supplier, fell as well.

“It saves lives,” Linda Thomas-Greenfield, the U.S. ambassador to the U.N., told the Security Council on Friday. “The world needs this grain. It must flow freely.”

Ukraine’s prime minister, Denys Shmyhal, on Friday called Russia’s insistence on a shorter term for the deal “a manipulation for further blackmail and fomenting a global food crisis.”

Talks on extending the deal began Monday in Geneva. Agreement on the previous extension, in November, was reached with days to spare.