Profile: Yousuf Raza Gilani
Pakistan's Prime Minister Yousuf Raza Gilani has proved himself to be a wily and resilient political operator who up until June 2012 had persistently defied his critics and the might of the judiciary to cling onto his job.
But it appears that defiance has finally came to an end with his shock disqualification from office by Pakistan's Supreme Court.
Its announcement came two months after it convicted the premier of contempt because of his refusal to ask Swiss authorities to reopen corruption cases against President Asif Ali Zardari.
Mr Gilani's strategy of not appealing against his conviction so as not to antagonise the court appears to have failed.
His determination to stand up for himself helped Mr Gilani grow in stature in the eyes of many Pakistanis.
He became the longest-serving prime minister in the history of Pakistan, where civilian governments have been repeatedly overthrown by the powerful military, often with the support of the Supreme Court.
When he was appointed to the job in March 2008 many commentators did not expect his tenure would be long. But he repeatedly rose to the challenge and fended off his critics.
In April 2012, Mr Gilani seemed in a stronger position than at any point during his confrontation with the Supreme Court.
Although he was found guilty of contempt, the court gave him only a symbolic sentence and he did not have to serve any time in jail. The prime minister had argued that the president, who rejects the charges, had immunity as head of state.
In April, the court in effect backed down from its efforts to remove the elected prime minister, and its symbolic judgement and token sentence were seen as something of a personal victory for Mr Gilani - the judiciary, the army and the opposition had apparently failed in their efforts to remove him.
It is not clear whether Mr Gilani will now try to appeal against his disqualification. The ruling Pakistan People's Party should have the necessary majority in parliament to elect a new prime minister.
In spite of his conviction, Mr Gilani emerged from his trial with his reputation enhanced, having succeeded in portraying himself as a man defending democracy in the face of a politically motivated campaign against him and his government.
Throughout his time in office it was clear that whatever the criticisms levelled at him - from poor governance to corruption - no party wanted to be seen as the one to bring down yet another elected government in Pakistan.
Supporters said that his long period as PM reflected Mr Gilani's sound political judgement and staying power.
He refrained from followed the bidding of former President Pervez Musharraf, despite heavy pressure by his government to coerce him into joining many of his Pakistan People's Party (PPP) colleagues in switching sides.
Mr Gilani's refusal to do a deal with Mr Musharraf is much admired within his party.
He went to jail in 2001, serving five years following a conviction over illegal government appointments that were alleged to have taken place during his term as Speaker of parliament between 1993-96.
A tall, softly-spoken man with an air of authority, he has acquired a reputation for doing the right thing.Political family
Yousuf Raza Gilani was born on 9 June 1952 in Karachi in the southern province of Sindh, but his family comes from Punjab.
The Gilanis are among the most prominent of landowners and spiritual leaders in the south of Punjab province. Their home town is the ancient city of Multan.
The family's prominence naturally led to its members vying for political power.
Mr Gilani's grandfather and great-uncles joined the All India Muslim League and were signatories of the 1940 Pakistan resolution. This was the declaration which eventually led to partition.
His father, Alamdar Hussain Gilani, served as a provincial minister in the 1950s.
Mr Gilani joined up in 1978 when he became a member of the Muslim League's central leadership.
This was soon after he completed his MA in journalism at the University of Punjab. His first term as a public servant was as a nominee of General Zia-ul-Haq.
The then Pakistan army chief had been the country's dictator since overthrowing elected Prime Minister Zulfiqar Ali Bhutto in a 1977 coup.
Mr Bhutto was executed in 1979, an act that forever soured the relationship between the army and the PPP.Figurehead
Mr Gilani joined Mr Bhutto's PPP in 1988, months before Gen Zia's death brought an end to its political exile.
Observers say it is his loyalty and his disdain for politicking within the party that earned him the nomination for prime minister.
"[Mr Gilani] was perhaps the only man among the top leadership who did not badger Zardari for this or any other position," says one PPP insider. "This along with the fact of his proven loyalty, earned him the nod."
But it was his independent thinking that won him many admirers after taking over as the country's chief executive.
Correspondents say his first few months were uncomfortable, with many doubting whether he had the charisma and standing to lead the country.
This feeling was strengthened when Mr Zardari, the PPP chairman, was elected president.
It was felt Mr Zardari would now take a more hands-on approach to government - leaving Mr Gilani as little more than a figurehead.
That did not happen and Mr Gilani grew in stature as his term progressed.
He had to contend with some of the worst crises in Pakistan's history, including extensive flooding, rising Taliban militancy and deteriorating relations with the US after the killing of al-Qaeda leader Osama Bin Laden.