JOHANNESBURG, July 19 (Reuters) - Russian President Vladimir Putin will not attend a summit of the BRICS nations in August, South Africa said on Wednesday, ending months of speculation about whether the country would arrest him on an international warrant.

South Africa faced a dilemma in hosting the summit because, as a member of the International Criminal Court (ICC) that issued the warrant in March, it would be obliged to arrest Putin for alleged war crimes by Russia during its invasion of Ukraine.

Russian Foreign Minister Sergei Lavrov will be at the Johannesburg summit on Aug. 22-24 instead of Putin, alongside the leaders of Brazil, India, China and South Africa, South Africa's presidency said in a statement.

The announcement followed consultations on Tuesday night between South African President Cyril Ramaphosa and leaders of political parties from the BRICS group of emerging economies.

The Kremlin said Putin would dial into the BRICS summit by video call.

The ICC's arrest warrant for Putin accuses him of the war crime of illegally deporting children from Ukraine.

Moscow has said the warrant is legally void as Russia is not a member of the ICC. It has not concealed a programme under which it has brought thousands of Ukrainian children to Russia, but presents it as a humanitarian campaign to protect orphans and children abandoned in the war zone.

A court filing made public on Tuesday showed Ramaphosa had asked permission from the ICC not to arrest Putin because doing so would amount to a declaration of war and potentially scupper African efforts to end the war in Ukraine.