CAIRO - Egypt's state grains buyer has agreed to replace a detained Ukrainian wheat shipment with a new 60,000-tonne cargo, according to two people with knowledge of the matter, following weeks-long negotiations to either free or replace the shipment.

The General Authority for Supply Commodities (GASC) will buy a new cargo of Russian or Ukrainian wheat from the same supplier, Olam, at a price of $361.25 per tonne on a cost and freight basis, one of the people added.

That is the same price that was agreed for the original 60,000 tonne cargo, the person said. The new cargo will be shipped between Sept. 15 and Oct. 15.

The original cargo was purchased by GASC in a December tender for shipment in February but has been stuck on board a vessel named Emmakris III at the port of Chornomorsk since Russia's invasion of Ukraine on Feb. 24. The ship was detained in July at the request of Ukraine's prosecutor general to investigate its alleged Russian ownership.

In August, Ukraine's Middle East envoy said Ukrainian officials were working to release the ship.

In the case of inability to deliver a cargo, GASC's tender book requires suppliers to fulfil contractual quantity from an alternative origin as GASC's tender book does not contain a provision for force majeure.

GASC, however, did release suppliers of four Ukrainian wheat cargoes bought before the war but never loaded on a vessel from their contractual obligations in July.

Both people with knowledge of the matter said GASC cancelled its contract with GTCS, the shipper of the older cargo. The new agreement with Olam would free GASC of any additional costs, as well as any responsibility towards the older shipment, one of them added.

The supply ministry did not respond to a request for comment.

Egypt's strategic wheat reserves currently stand at 6.6 months, Supply Minister Ali Moselhy said on Monday.

(Reporting by Sarah El Safty, Editing by Aidan Lewis, Alexandra Hudson)