By Syed Shoaib Hasan
BBC News, Islamabad
Mr Gilani comes from a family of Punjab landowners
Pakistan's Prime Minister Yusuf Raza Gilani had a reputation for doing "the right thing", no matter what the cost personally.
By his own admission, this precluded him from being one of the "good boys" who followed the bidding of former President Pervez Musharraf.
The regime tried to coerce him into joining many of his Pakistan People's Party (PPP) colleagues in switching sides.
But Mr Gilani refused to do a deal with Mr Musharraf and his loyalty is much admired within his party.
He went to jail in 2001, serving five years following a conviction over illegal government appointments.
This was during his term as Speaker of parliament between 1993-96.
The sentence was passed by an anti-corruption court formed by President Musharraf as part of what he termed measures to cleanse politics. His opponents say it was a means of intimidating and coercing their members to join his government.
For Mr Gilani that was never a choice, his supporters say. A tall, softly-spoken man with an air of authority, he is known for doing the right thing, supporters say.
In 1995, Mr Gilani issued instructions for the release of parliamentarians detained by his own PPP government.
When the interior ministry refused to oblige, he had the matter brought on record - a quite unprecedented action.
His remarks after he was sentenced in 2001 were similarly unequivocal.
He told the Dawn newspaper that the charges were "concocted and were fabricated to pressurise him to leave the PPP".
"Since I am unable to oblige them, they decided to convict me so that I could be disqualified and an example set for other political leaders who may learn to behave as good boys," he said at the time.
His stance and defiance won him many admirers, even among the government.
Anti-establishment politics and leadership is seen as something of a birth right for him.
He was born on 9 June 1952 in Karachi but his family comes from the Punjab.
The Gilanis are among the most prominent of landowners and spiritual leaders in the south of the province. Their home town is the ancient Punjabi city of Multan, one of the oldest unbroken human settlements in the world.
The family's prominence naturally led to its members vying for political power.
His 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 Pakistan Army chief had been the country's dictator since he overthrew elected Prime Minister Zulfiqar Ali Bhutto in a 1977 coup.
Mr Bhutto was later executed in 1979, an act that forever soured the relationship between the army and the PPP.
Mr Gilani was elected as the chairman of the Multan union council in 1983.
Two years later he was elected to the federal parliament. It was during this first stint that circumstances arose which led to his leaving the League.
While serving as a minister he fell out with then Prime Minister Mohammad Ali Junejo. This led to him being replaced as minister and sidelined in the party.
In his book, Chah-e-Yusuf ki Sada (Reflections from Yusuf's Well), which he wrote in jail, he said: "I was furious, and helpless at the same time, I knew I could not continue... and then I made up my mind."
Mr Gilani says he went to Karachi to meet Benazir Bhutto, Zulfiqar Bhutto's daughter, then very much in the political wilderness.
General Zia was still in power and the PPP faced an uncertain future. Mr Gilani says he presented his offer to immediately join the PPP.
"Ms Bhutto said to me, 'There is nothing I can offer you, why have you come?'"
Mr Gilani said his reply was what sealed his relationship with the PPP and the Bhuttos.
"I said to her, there are three types of people in this world - lovers of honour, of wisdom and of wealth. I am of the first type, and that is all I want."
Soon afterward, General Zia dismissed Mr Junejo's government. Mr Gilani then joined the PPP, months before the general's death bought 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 is his independent thinking that has won him many admirers since taking over as the country's chief executive.
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 PPP chairman Asif Ali Zardari was elected president of Pakistan.
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 has not happened and Mr Gilani has grown in stature as his term has progressed.
In fact, it was he who came to Mr Zardari's rescue during a stand-off in the spring of 2009 with Pakistan's main opposition leader Nawaz Sharif.
His political negotiating skills were able to broker a solution apparently to the satisfaction of all.
At the moment, he has taken on the mantle of heading Pakistan's political leadership as it unites against the threat of the Taliban militants.