Gilani was charged with contempt for his refusal to pursue a long, dormant corruption case against his political master, President Asif Ali Zardari. The court could have sent him to prison for six months and ordered his immediate dismissal from office, but appeared to blink first in what has been a bruising standoff.
"The prime minister has not been convicted of any moral crime. No one needs to give us a lesson in morality," said Information Minister Qamar Zaman Kaira, adding that the verdict would be appealed.
Gilani is the longest-serving prime minister in the coup-studded history of Pakistan. The government he heads is woefully inept and corrupt, according to foreign diplomats and analysts, but many democracy activists say it should be allowed to complete its term and have elections decide the next government.
Gilani arrived at the imposing court building on foot, flanked by government ministers and in showers of pink rose petals tossed by supporters.
A seven-judge panel read out a ruling that found him guilty of contempt and sentenced him to prison only "until the rising of the court," or by the time the judges left the chamber. That happened about a minute after the verdict was handed down.
The parliamentary speaker and election commission must now decide whether the conviction is reason to dismiss Gilani as a lawmaker, and hence as prime minister, a procedure outlined in the constitution but one that could take up to four months and be contested legally every step of the way. With elections later this year or early next, Gilani could yet see out his term.
American envoy Mark Grossman is making his first visit to Pakistan since Islamabad blocked U.S. and NATO supply routes to Afghanistan in November in protest over U.S air raids that killed 24 Pakistani troops along the mountainous western border.
Pakistan used the incident to try to extract better terms from Washington, which sees Pakistan as an essential if unreliable ally against al-Qaida and vital to the sustainability of any peace deal with insurgents fighting in neighboring Afghanistan.
The country is demanding that Washington apologize for the border incident and halt attacks by drone aircraft against militants in northwest Pakistan. U.S. officials regard the strikes as essential to the fight against al-Qaida and associated groups.
The envoy, Mark Grossman, said he didn't expect to get an immediate commitment that the supply routes would reopen but that "the task now is to begin a conversation about how to move forward." Grossman, who is Washington's envoy for Afghanistan and Pakistan, also repeated earlier U.S. statements of regret for the November airstrikes but didn't apologize.
It's unclear whether the uncertainly surrounding the future of Gilani will directly impact the negotiations. Grossman met Pakistan's army chief to discuss the supply routes, according to an army statement. The army is the real power center in Pakistan, especially in dealings with the United States and Afghanistan.
Pakistan's opposition leader, Nawaz Sharif, said Gilani's conviction meant he should resign.
"He would be insulting the Parliament by continuing," he said. "He should resign to avoid any further crisis."
Members of Gilani's party and his coalition partners may well also pressure him to step down, figuring it's time to ditch a leader who has been convicted in a court of law, analysts said. The ruling Pakistan's Peoples Party should have the numbers in parliament to elect a replacement, but it may not be smooth.
"It's a political decision now," said Cyril Almeida, a political commentator. "Is the damage they sustain having Gilani continue in office less than the benefits of having a martyr at the helm?"
In the world of Pakistani politics, the conviction against Gilani could become an advantage to his and Zardari's Pakistan's Peoples Party. It could portray the case against Gilani as the latest in a long line of unjust decisions by the courts and the army and use it to fire up the party's base ahead of elections. Party founder Zulfikar Ali Bhutto was hanged by the court in 1979.
Thursday's verdict was the culmination of a process that began in a Supreme Court decision in 2009 ordering the government to ask authorities in Switzerland to reopen the corruption probe against Zardari dating back to the 1990s. Gilani refused, saying the president had immunity from prosecution, and in January the court ordered contempt proceedings against him.
Government loyalists have accused the chief of the Supreme Court of having a feud against Zardari. Supporters of the judiciary say it is trying to uphold the law in a country where the country's politicians have engaged in massive corruption for years.