Pakistani Prime Minister Yousuf Raza Gilani , seen here in Islamabad on Feb. 11, 2012, could go to jail on contempt charges. (AAMIR QURESHI/AFP/GETTY IMAGES)

They now inhabit regal mansions in the nation’s capital, but the prime minister and the president of Pakistan have known their share of more lowbrow addresses — namely, jail cells.

For Pakistani politicians, getting tossed into prison — whether for shameless plunder and graft or trumped-up charges brought by vindictive foes — is an occupational hazard.

Now, some observers predict that Prime Minister Yousuf Raza Gilani is headed back behind bars. The Supreme Court on Friday denied his attempt to block his prosecution and ordered him to appear in court on Monday to be indicted on contempt charges.

The charge, which carries six months in jail and possible removal from office, stems from Gilani’s adamant refusal to pursue an old money-laundering case brought by Swiss authorities against President Asif Ali Zardari. Gilani has asserted that the constitution grants Zardari immunity, but the court insists rule of law would be subverted if the prime minister were allowed to flout its orders.

Gilani, who has held his job since 2008 and is the longest-serving prime minister in Pakistan’s history, has said he will go to jail if the court orders him to. That prospect has raised fears that Pakistan’s fragile democracy could well collapse at a time when the nuclear-armed, strategically vital country is already wracked by an Islamist insurgency, severe energy shortages and economic crisis.

“Frankly, we are going toward anarchy very, very soon,” warned Sen. Safdar Abbasi, a member of the ruling Pakistan People’s Party who has long called for Gilani to cooperate with the courts. The contempt battle has dominated political discourse for too long, he added, while leaders ignore the pressing problems of their constituents.

“The government should end this crisis,” Abbasi said. “It’s like playing with a loaded gun.”

Because Gilani and Zardari were never particularly close, pundits are still puzzling out the prime minister’s motivations for risking his job for Zardari, who has dismal popularity ratings and a long rap sheet of kickback, shakedown and other corruption allegations.

Some see the 59-year-old prime minister finally shedding his unassuming personality and coming into his own. “He has shown backbone, he has shown grit,” said Ayaz Amir, an opposition member of parliament and columnist.

The contempt charge stems from a 2009 Supreme Court ruling that declared unconstitutional a national amnesty enacted two years earlier. That amnesty cleared Zardari and thousands of others of past alleged crimes. The court ordered the government to write a letter to Swiss authorities requesting that they reopen the corruption cases against Zardari, who was investigated along with Benazir Bhutto, his late wife and a former prime minister, for their financial dealings there in the 1990s.

Besides staring down the court, Gilani recently lashed out at the country’s powerful military and intelligence establishment. During an episode known here as Memogate, he bristled at the military’s efforts to control the investigation of a mysterious missive that sought U.S. help in averting a coup d’etat after the killing of Osama bin Laden in Pakistan.

Gilani asserted in a December speech that there was no place for a “state within a state” that claimed national security and foreign policy authority that should belong to the civilian leadership. Although he would later temper his criticism, the prime minister said then that control of the military resides in the executive branch.

The speech struck many as remarkable in its defiance, given the military’s penchant for dethroning elected governments. “Very few civilians have stood up to the army and lived to tell the tale, so to speak,” Amir noted.

Gilani hails from an influential family in Multan, a southern city in Punjab province, and entered politics when he was 26. Bhutto picked Gilani to be speaker of the National Assembly during her first term in office in the early 1990s. That stint led later to accusations of patronage and abuses of power, and Gilani was arrested in 2001 by the government of Gen. Pervez Musharraf.

A court freed Gilani in 2006, after he served more than five years. Nusrat Javeed, a columnist and TV anchor, said that at one point, both the future prime minister and the future president were incarcerated at the same facility, in Rawalpindi. All told, Zardari spent 11 years in prison in Pakistan but was never convicted.

Gilani came to power in 2008 as the consensus candidate after the PPP won elections held in the aftermath of Bhutto’s assassination. Having survived this far into his five-year term in coup-prone Pakistan, Gilani may not care if he has to leave office: “He might be thinking, ‘I have already made history — the Supreme Court can do what it wants,’ ” Javeed said.

Another theory holds that Gilani wants to go out as a selfless political martyr who showed his unflagging party fealty to the very end. Such sacrifice would leave a dynastic legacy for his children, who also are involved in politics.

Some PPP officials insist that there is no replacement for Gilani in the wings, but say the party will stand by his decision if he is continues to defy the court and is forced to resign.

Then there’s another option, according to party insiders: Zardari could pardon Gilani immediately after he’s convicted.