The seven-judge bench headed by Justice Nasir-ul-Mulk ruled that Gilani's punishment would last till the rising of the court or till the completion of the hearing, during a session that lasted 10 minutes, the Press Trust of India reported. Gilani was seen smiling when the verdict was read out.
The judges left the courtroom No 4 immediately after issuing the verdict, effectively limiting Gilani's detention to less than a minute.
Legal experts stay divided on whether the 56-year-old Gilani can be disqualified under Article 63 of the constitution for having been convicted in a court. However, the procedure to disqualify him could be lengthy and complicated.
Gilani was convicted of contempt because he had refused to write a letter to the Swiss authorities despite the Supreme Court order which overturned an amnesty on corruption case against Zardari. The maximum sentence for the case against Gilani was six months.
Gilani said the symbolic punishment was not appropriate.
The government has been under pressure from the Supreme Court to revive the cases against President Zardari for laundering millions of dollars in bribes from Swiss firms. But the Gilani administration refused to take action, claiming that the President enjoyed immunity in Pakistan and abroad.
Zardari and his slain wife Benazir Bhutto were convicted by a Swiss court of money laundering in 2003 while they were in the government. However, the Swiss authorities dropped the charges in 2008, following a request from the Pakistani government led by Bhutto's Pakistan's People's Party.
However, Pakistan's Supreme Court ruled in 2009 that the official pardon was unconstitutional, which put pressure on the government to reopen the case.
Zardari argued that the calls to revive the case were politically motivated.
Meanwhile, the opposition has demanded Gilani's resignation and called for fresh elections.
The court verdict is based on truth and reality. It must have punished the Prime Minister with a heavy heart, but the prime minister himself is to be blamed.
The Prime Minister himself invited this situation, he added.
Jamaat-e-Islami chief Munawar Hussain also called for Gilani to quit as he had lost moral ground after the judgment.
The Supreme Court sentenced him in an honorable manner and it also got its verdict implemented. He is now a convicted person and he cannot remain prime minister now, said Hussain.