Culminating months of standoffs and skirmishes between the country's highest court and the government, the court sentenced Mr. Gilani to detention but only until the court adjourned a few minutes later. It was the most lenient sentence possible.
While the verdict was seen as largely symbolic, Mr. Gilani could still face problems because he has been convicted, a result that could mean the prime minister could face removal from office in the months to come.
The case has riveted Pakistan's brittle political system, driving a wedge between the government and the judiciary as the country faces pressing economic and security threats. Yet both sides have adopted entrenched positions.
The case focused on a letter the Supreme Court ordered Mr. Gilani to write to the authorities in Switzerland to revive a dormant corruption investigation into the finances of President Asif Ali Zardari. Mr. Gilani refused to comply, arguing that Mr. Zardari has immunity from prosecution.
Analysts had said a guilty verdict could carry Pakistan into new legal territory, with potentially stark implications for the Zardari government. Having survived speculation about a military coup in January, the government now hopes to complete its five-year term a year from now, when elections are scheduled.
Rooting out corruption is an old problem in Pakistan, where bribery, kickbacks and nepotism are endemic among politicians, generals and even cricketers, but the means to prosecute them have become heavily politicized. In politics, and the military, corruption is seen as a way of either feathering one's own nest or tarring a rival's. Virtually every political leader - and many military ones - have faced similar accusations.
The Supreme Court aimed to show that it has the will and power to change that. On Wednesday evening soldiers were posted at checkpoints in Islamabad in anticipation of a day of high political theater, with television stations expected to broadcast coverage.
Yet the clash has one strange aspect: The "Swiss letter," as it is known, at the heart of the affair, could prove to be meaningless. In interviews by phone from Geneva, Swiss lawyers and a senior magistrate who had been involved in the cases said it would be virtually impossible to revive the cases against Mr. Zardari at this point.
One obstacle, they said, was his immunity as head of state; another is Switzerland's 15-year statute of limitations, which expires this year. A third is the exasperation of the Swiss authorities.
"Switzerland is not some yo-yo you can play with," said Daniel Zappelli, a former state prosecutor who drew up charges against Mr. Zardari in the 1990s. "You can't say one day you will go with the case, and then next day that you won't. We spent basically 10 years working with the parties in Pakistan to review everything, and we mightn't be so hot to do all that work again."
Mr. Zappelli resigned as Geneva prosecutor on March 31; a spokeswoman for his successor, Olivier Jornot, would not comment.
The Swiss reluctance raises a question: Why are Pakistan's judges and leaders willing to go toe-to-toe over a potentially meaningless gesture?
The conflict stems partly from the aggressiveness of the Supreme Court under Chief Justice Iftikhar Muhammad Chaudhry, which often challenges the authority of a government it paints as incompetent and corrupt.
Critics say the court sometimes goes too far, and may be driven by personal motives. Justice Chaudhry is a bitter rival of Mr. Zardari, who resisted his reinstatement as chief justice in 2009. Some analysts believe that by prosecuting the prime minister, the court has overreached.
"The Supreme Court, like the military, thought they could scare this government into compliance," said Cyril Almeida, a writer at Dawn, a major English-language newspaper. "Now the government has called their bluff."
© 2012, The New York Times News Service