An agreement allowing Ukrainian grain to ship through the Black Sea has been extended for two months just a day before its expiration — overcoming Russia’s threats to pull out of the deal.