Somalia's President Abdullahi Yusuf Ahmed has told parliament he is resigning.
The news comes a few days after the resignation of the man he had recently appointed as prime minister.
Ex-Prime Minister Mohamed Mahamud Guled quit last week saying his appointment was destabilising the government.
Mr Yusuf, elected four years ago, said he had failed to bring peace. The parliament speaker would take over leadership responsibilities.
'Failed in duty'
He addressed parliamentarians in Baidoa, saying: "As I promised when you elected me on October 14, 2004, I would stand down if I failed to fulfil my duty, I have decided to return the responsibility you gave me."
In his speech, broadcast on national radio, he said: "When I took power I pledged three things.
"If I was unable to fulfil my duty I will resign. Second, I said I will do everything in my power to make government work across the country. That did not happen either.
"Third, I asked the leaders to co-operate with me for the common good of the people. That did not happen," he said, according to Associated Press news agency.
Mr Yusuf had faced criticism for appointing Mr Guled in defiance of Somali MPs, who said the dismissal of his predecessor, Nur Hassan Hussein, two weeks previously, had been illegal.
The president had clashed in recent months with Mr Nur over attempts to negotiate a peace deal with the Islamist-led armed opposition.
Mohamed Mahamud Guled said he had chosen to resign "so that I am not seen as a stumbling block to the peace process which is going well now".
Somalia has been without an effective central government since President Siad Barre was overthrown in 1991.