Iraq's Nuri al-Maliki, a rebel-turned-leader who rose from anonymous exile to powerful premier widely criticised as authoritarian, fought to the end for another term but lost support and ultimately his office as security collapsed.
After a strong showing in April polls, the two-term premier insisted the top job should again be his, but President Fuad Masum tasked Haidar al-Abadi, a member of Maliki's Dawa party, with forming a new government instead.
Maliki, a 64-year-old Shiite Arab, vowed to sue Masum, a Kurd, railed against him for allegedly violating the constitution, and ordered a massive security deployment in Baghdad.
But international backing poured in for Abadi, and the office of Iraq's top Shiite cleric, who is revered by millions, released a letter calling for the premier to go.
"I announce before you today... the withdrawal of my candidacy in favour of the brother Doctor Haidar al-Abadi," Maliki said in a televised address on Thursday, with his successor at his side.
The announcement marks the end of his controversial time in power, which began in 2006, when he was regarded as a weak compromise candidate who emerged from the shadows to become premier.
He has since undergone several transformations, from a nationalist who battled militiamen from his own Shiite community and presided over a sharp decline in violence to being accused of amassing power and sidelining partners.
Maliki's eight years in office was markedly different from his life before the 2003 US-led invasion.
Born Nuri Kamal al-Maliki in a predominantly Shiite town south of Baghdad, he joined the Islamic Dawa party -- the oldest Iraqi movement opposed to Saddam Hussein -- while at university.
He fled in 1979 after the dictator banned the party, and Dawa says he was later sentenced to death in absentia.
From 1980, he lived in Iran and then Syria, where he edited Dawa's newspaper. In exile, he adopted the nom de guerre Jawad and coordinated cross-border raids from Iran into Iraq.
He returned after Saddam's ouster in the 2003 US-led invasion and became a member of the de-Baathification commission that barred Saddam supporters from public office.
- Thrust to power -
In 2006, the dour bespectacled politician was named premier after his predecessor Ibrahim al-Jaafari, also a Shiite, was regarded as too sectarian by Sunnis and Kurds.
Thrust to power at the height of Iraq's brutal sectarian war that killed thousands of people each month, Maliki was then seen as politically weak.
But he stayed in office and with US military backing, he pursued an offensive against the militia of powerful Shiite cleric Moqtada al-Sadr in 2008.
The successful assault won him plaudits across the communal spectrum, and he staked his reputation as a nationalist leader who had brought Iraq's raging violence under some semblance of control.
Under Maliki, American forces withdrew in late 2011 and oil production has steadily increased.
Since being re-elected premier in 2010 at the head of a national unity government, however, Maliki has faced near-constant political crises, and the security gains of his first term in office have been disastrously reversed.
His critics accuse him of consolidating power, particularly within the security forces, and blame him for a sharp deterioration in security.
In the years since the American withdrawal, Maliki has repeatedly feuded with Iraqi Kurds and Sunni Arabs, the country's two main minority groups, prompting charges of discrimination and sectarianism.
Widespread Sunni anger with Maliki's government has had especially dire consequences, combining with the brutal civil war in neighbouring Syria to fuel rising bloodshed in which hundreds of Iraqis have been killed per month.
Maliki did little to placate the Sunnis and responded to the the violence, which has spiked since April 2013, with wide-ranging military operations.
The operations, which mainly targeted Sunni-majority areas, resulted in hundreds of arrests and increased already-high resentment, but did not curb the violence.
In late 2013, security forces dismantled the country's main Sunni Arab anti-government protest camp, which Maliki said had become a headquarters for militants, setting of a chain of events that saw Baghdad lose control of all of one city and part of another to insurgents.
The security collapse culminated in a jihadist-led militant offensive launched in June that swept security forces aside and overran large areas of five provinces.
Major domestic discontent and international pressure for the selection of a premier with a better chance of forming a broad-based government to counter the militant takeover combined to undercut Maliki's bid for a third term.
But his decision to step aside ultimately defied the label of dictator that his opponents gave him, and allows Iraq's fledgling democracy to move forward.