KYIV, Ukraine (AP) — Diplomatic efforts salvaged a wartime agreement that allowed Ukrainian grain and other commodities to reach world markets, with Russia saying Wednesday it would stick to the deal after Ukraine pledged not to use a designated Black Sea corridor to attack Russian forces.

But Russian President Vladimir Putin warned that Moscow reserves the right to withdraw again from the agreement if Kyiv breaks its word.

“We demanded assurances and guarantees from the Ukrainian side that … humanitarian corridors will not be used for military purposes,” Putin told a Security Council meeting, according to Russian state news agencies. “I have given instructions to the Ministry of Defense to resume our full participation in this work.”

The Russian leader praised Turkey’s mediation efforts to get the deal back on track as well as Turkish President Recep Tayyip Erdogan’s “neutrality in the conflict as a whole” and his efforts at “ensuring the interest of the poorest countries.”

Russia suspended its participation in the grain deal over the weekend, citing allegations of a Ukrainian drone attack against its Black Sea fleet in Crimea. Ukraine did not claim responsibility for the alleged attack.

Erdogan said the renewed deal would again come on stream Wednesday, prioritizing shipments to African nations, including Somalia, Djibouti and Sudan. That’s in line with Russia’s concerns that most of the exported grain had ended up in richer nations since Moscow and Kyiv made separate agreements with Turkey and the U.N. in July.

U.N. humanitarian chief Martin Griffiths said Monday that 23% of the total cargo exported from Ukraine under the grain deal went to lower or lower-middle income countries, which also received 49% of all wheat shipments.

U.N. Secretary-General Antonio Guterres hailed Russia’s announcement putting the deal back on track. U.N. spokesman Stephane Dujarric said Guterres “remains committed to removing the remaining obstacles to the exports of Russian food and fertilizer.”

Ukraine and Russia are key global exporters of wheat, barley, sunflower oil and other food to developing countries where many are already struggling with hunger. A loss of those supplies before the grain deal pushed up global food prices and helped throw tens of millions into poverty, along with soaring energy costs.

The July grain agreement brought down global food prices about 15% from their peak in March, according to the U.N. After the announcement of Russia rejoining the deal, wheat futures prices erased increases seen Monday, dropping more than 6% in Chicago.

Meanwhile in Ukraine, thousands of homes in the Kyiv region and elsewhere remained without power, officials said Wednesday, as Russian drone and artillery strikes continued to target the country’s energy infrastructure.

Kyiv region Gov. Oleksiy Kukeba said 16,000 homes were without electricity and drones attacked energy facilities in the Cherkasy region south of the capital, prompting power outages.

Although power and water were restored to the city of Kyiv, Kuleba didn’t rule out electricity shortages lasting “weeks” if Russian forces continue to hit energy facilities there. In a Telegram post, he accused Russian forces of trying to prompt a serious humanitarian crisis.

Power outages were also reported in the southern cities of Nikopol and Chervonohryhorivka following “a large-scale drone attack,” Dnipropetrovsk Gov. Valentyn Reznichenko said.

The two cities are located across the Dniper River from the Zaporizhzhia Nuclear Power Plant, Europe’s largest nuclear facility. Russia and Ukraine have for months traded blame for shelling at and around the plant that the U.N.’s nuclear watchdog warned could cause a radiation emergency.

In a development easing such fears, Ukraine’s state nuclear company Energoatom said the Zaporizhzhia plant has been reconnected to the country’s power grid after Russian shelling forced the facility to rely on generators to cool its spent nuclear fuel.

Energoatom’s press service told the Associated Press in a written statement that some of the eight power lines serving the Russian-held plant have been restored, but wouldn’t specify the number citing fears of renewed Russian shelling.

With its six reactors inoperative, the plant relies on outside electricity to cool its spent fuel. Although Putin signed a decree transferring the plant to Russian ownership, Ukrainian staff continues to run it.

Energoatom has repeatedly called for the withdrawal of Russian from the plant and for the creation of a demilitarized zone around it.

The company also said Russian soldiers have cordoned off the plant’s spent nuclear fuel storage facility and began unspecified construction there. It alleged that inspectors from the U.N. nuclear watchdog, the International Atomic Energy Agency, who have been present at the site since early September have been barred from the area.

“The Russians are building incomprehensible things at the nuclear fuel storage facility. They don’t let anyone in, they don’t report anything,” the company said.

On a visit to Kyiv Wednesday, Spain’s Foreign Minister José Albares pledged a new military aid package to help Ukraine’s air defenses. Speaking after talks with Kuleba, Albares didn’t disclose specifics about the arms or when they’ll be delivered, citing security concerns.

Continued Russian shelling in southern and eastern Ukraine caused at least four civilian deaths and wounded 17 others between Tuesday and Wednesday, according to the office of Ukrainian President Volodymyr Zelenskyy.

The shelling also pounded cities and villages retaken by Ukraine last month in the northeastern Kharkiv region, wounding seven people.

Russian fire damaged a hospital and apartment buildings in the Donetsk region city of Toretsk. Donetsk Gov. Pavlo Kyrylenko said Wednesday Ukrainian and Russian forces continued to fight for control of the cities of Avdiivka and Bakhmut, both key targets of a Russian offensive in the region.

Ukraine’s Deputy Defense Minister Hanna Malya told Ukrainian TV that Ukrainian defenders around Bakhmut were facing a “very difficult” task, with “fierce battles” raging around the city.

In southern Ukraine, Russian-installed authorities in the occupied Kherson region relocated civilians some 90 kilometers (56 miles) further into Russian-held territory in anticipation of a major Ukrainian counterattack to recapture the provincial capital of the same name. Russian forces dug trenches to prepare for the expected ground assault.

The Kherson region’s Kremlin-appointed officials on Tuesday expanded an evacuation area to people living within 15 kilometers (9 miles) of the Dnieper River. They said 70,000 residents would be relocated this week, doubling the number moved earlier.

In another development, Belarus and Russia began preparations Wednesday for large-scale joint military exercises. Belarusian Defense Minister Viktor Khrenin didn’t specify either the dates on which the exercises, dubbed Union Shield-2023, will be held or the number of troops that will take part.

Russia has previously used Belarus, a long-standing and economically dependent ally, as a springboard to send both troops and missiles into Ukraine. Kyiv fears that the Belarusian army will be directly drawn into the war, striking from the north where the countries share a 1,080-kilometer (671-mile) border.