Iraqi Prime Minister Nouri Maliki has resigned, in a move observers hope will end a political crisis in Baghdad.
Haider al-Abadi, a deputy speaker of parliament, has been asked by Iraq’s president to form a government.
Mr Maliki’s earlier refusal to resign after eight years in power had been blamed for deepening the crisis. The UN and US have welcomed his resignation.
The government has been unable to stop Islamist fighters from seizing vast areas in northern Iraq.
The offensive by the self-styled Islamic State (IS), a Sunni Muslim jihadist group formerly known as Isis, has triggered a security and humanitarian crisis, driving an estimated 1.2 million Iraqis from their homes.
Appearing on state TV flanked by Mr Abadi and other politicians from the Shia Muslim majority, Mr Maliki spoke of the grave “terrorist” threat from IS before announcing his own exit.
“I announce before you today, to ease the movement of the political process and the formation of the new government, the withdrawal of my candidacy in favour of brother Doctor Haider al-Abadi,” he said.
Analysis: Jim Muir, northern Iraq
His eight years in office, Mr Maliki said, had been spent combating a mounting wave of terrorism and subversion. He insisted that he had stuck to the law and avoided violence even when he had come under personal attack but now, he said, he did not want to be the cause of the shedding of a single drop of blood.
There had been fears that Mr Maliki might use the power base he built up through his control of the armed forces to stay in power.
But, with his own party and the Shia clerical establishment, not to mention influential outside powers such as Iran and America and the entire international community backing Mr Abadi, the writing was clearly on the wall for Mr Maliki’s hopes of clinging to power.
He had earlier insisted that he should have the right to form the government, as leader of the biggest bloc in parliament.
The resignation brought an end to eight years of often divisive rule, when Mr Maliki’s government was accused of favouring the Shia majority.
Critics say Mr Maliki’s sectarian policies had precipitated the current crisis.
Mr Abadi is one of Iraq’s most senior politicians, having held several high-profile posts since returning from exile in 2003.
He is regarded by some as a moderate within Mr Maliki’s Dawa party, and has shown more of a willingness to compromise than his predecessor.