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.
US National Security Adviser Susan Rice praised Mr Maliki's decision to step down, describing it as a "major step" towards uniting Iraq.
UN Secretary-General Ban Ki-moon said Mr Maliki's withdrawal "will allow the crucial process to form a new government to proceed swiftly".
"An inclusive, broad-based government ready to immediately tackle... pressing issues" was needed, he added.
Earlier, US President Barack Obama offered his support to the prime minister-designate.
"He [Mr Abadi] still has a challenging task in putting a government together, but we are modestly hopeful that the... situation is moving in the right direction," Mr Obama said.
Mr Obama also paid tribute to US forces for an operation in the north of Iraq that he said has helped tens of thousands of people displaced by IS.
Many of them, mostly from the Christian and Yazidi religious minorities, were besieged on Mount Sinjar after being forced to flee their homes.
Mr Obama said US forces had helped break the siege and the situation had greatly improved.
Thousands of Yazidis have reached camps inside Iraq's Kurdish region, most with no possessions but the clothes on their backs, AFP news agency reports from Dohuk.
Conditions in the camps are spartan, with one man, Khodr Hussein, saying: "We went from hunger in Sinjar to hunger in this camp."
In other developments:
- EU ministers will in Brussels on Friday to seek approval for the shipment of arms to Iraqi Kurds fighting IS
- The UN Security Council will vote on a draft resolution aimed at punishing the recruitment and financing of foreign fighters for IS
- The UK said on Thursday it would "favourably consider" any request for arms from the Kurds in their battle with extremists in Iraq.