UNITED NATIONS — Lakhdar Brahimi will resign as the joint UN-Arab League envoy on Syria after a nearly two-year effort that failed to bring peace to the war-ravaged country, the UN chief announced Tuesday.

With Brahimi at his side, UN Secretary-General Ban Ki-Moon, said the envoy will step down May 31. Ban pledged to keep working to achieve peace.

When Brahimi took the job, replacing his longtime friend, former UN secretary-general Kofi Annan, he said it would be “an extremely complicated and very, very difficult mission.”

Brahimi managed to get government officials and opposition to two rounds of peace talks in Geneva, but they ended without an agreement.

Brahimi had been working behind the scenes to restart the Geneva negotiations but that effort was all but doomed when President Bashar Assad’s government announced that elections would be held on June 3. The Geneva talks were intended lead to a transitional government.

Ban said Brahimi “faced almost impossible odds with the Syrian nation, Middle Eastern region, and … international community that have been hopelessly divided in their approaches to ending the conflict.”

“He has persevered with great patience and skill,” Ban said. “I regret that the parties, especially the government, have proven so reluctant to take advantage of that opportunity to end the country’s profound misery.”

The only achievement of the Geneva talks before they broke off in February was a week-long ceasefire in the central city of Homs to evacuate hundreds of civilians that have lived under a crippling army siege.

Assad’s forces earlier this week took full control of Homs following a ceasefire agreement with the rebels that allowed more than 2,000 opposition fighters to leave the city, which had been dubbed the “capital of Syrian revolution.”

The Syrian conflict started as largely peaceful protests against Assad’s rule in 2011. It turned into a civil war after some opposition supporters took up arms to fight a brutal government crackdown. Over the past year, the fighting has taken increasingly sectarian overtones, pitting largely Sunni Muslim rebels against Assad’s government that is dominated by Alawites, a sect of Shiite Islam.

Activists say more than 150,000 have been killed in the fighting.

Copyright 2014 The Associated Press.