Lakhdar Brahimi resigned Tuesday as the joint UN-Arab League envoy to Syria after trying for nearly two years to overcome "almost impossible odds" to end a civil war that has claimed more than 150,000 lives, the UN chief announced Tuesday.

With Brahimi at his side, UN Secretary-General Ban Ki-moon blamed the failure of the peace effort on the warring parties, but especially the Syrian government. He also blamed the deeply divided Security Council and countries with influence on the fighting sides. Ban pledged to keep working to achieve peace and urged all involved to rethink what they can do to bring hope to the Syrian people.

Ban said Brahimi will step down May 31. He said he will appoint a successor but gave no timetable.

Brahimi "faced almost impossible odds with the Syrian nation, Middle Eastern region, and wider international community that have been hopelessly divided in their approaches to ending the conflict," Ban said. "He has persevered with great patience and skill."

Brahimi is the second UN-Arab envoy to quit after failing to achieve a breakthrough in the more than 3-year-old conflict between the regime of President Bashar Assad and rebel groups.

When Brahimi took over from his longtime friend, former UN secretary-general Kofi Annan, he said it would be "an extremely complicated and very, very difficult mission." On Tuesday, he indicated he could see no end in the near future to the bloodshed.

"I'm sure that the crisis will end -- but the question is how many more dead? How much more destruction?" Brahimi said. "It's very sad that I leave this position and leave Syria behind in such a bad state."

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

He had been working behind the scenes to restart the Geneva negotiations but that effort was all but doomed when Assad's government announced that elections would be held on June 3. The Geneva talks were intended to lead to a transitional government, and with new elections on the horizon both Brahimi and Ban have indicated it would be impossible to get the opposition to new negotiations.

"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," Ban said. "I renew my appeal to them to show the wisdom and the sense of responsibility that could allow a way out of this nightmare."

Brahimi, 80, is a former Algerian foreign minister and longtime UN diplomat and troubleshooter in hotspots from Afghanistan to Iraq. He said he was humbled by Ban's "extremely generous words on this occasion which is not very pleasant for me."

Ban said "Mr. Brahimi has long been recognized as one of the world's most brilliant diplomats."

"That his efforts have not achieved effective support from the United Nations body that is charged with upholding peace and security, and from countries with influence on the Syrian situation, is a failure of all of us," Ban said.

Deep divisions between Russia -- which supports the Assad regime -- and Western countries -- which back the rebels -- have prevented the Security Council from taking any effective action on Syria's war.

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.

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."