In the second-ever Supreme Court appearance by a sitting prime minister, Gilani struck a conciliatory note but stuck to his guns in arguing that he could not ask Switzerland to reopen a corruption case against President Asif Ali Zardari.
"I have come today to show my respect to this court," Gilani told the seven judges. "It will not give a good message to proceed against a president who is elected by a two-thirds majority."
And he insisted, "There is complete immunity for heads of state everywhere."
But Justice Sarmad Jalal Osmany said that refusing to implement a court order is tantamount to contempt of court.
The case arises from the government’s refusal to implement a court order to write to the Swiss authorities about the Zardari graft case on the grounds that the head of state enjoys immunity from prosecution.
Although never convicted, Zardari spent 11 years in jail on charges including corruption and murder.
He and his late wife, Benazir Bhutto, were suspected of using Swiss bank accounts to launder about nine million euros allegedly paid in bribes by companies seeking customs inspection contracts in the 1990s when Benazir was prime minister.
A Swiss prosecutor has said it would be impossible to reopen the case wile Zardari is president because of the immunity question.
Gilani’s laywer, Aitzaz Ahsan – who is widely respected for helping win the reinstatement of judges fired by former military president Pervez Musharraf – asked the court for a month to prepare the case but judges told him he could have access to all necessary records within two days and set a new date for 13 days time.
Gilani could be jailed for six months and disqualified from public office if found guilty of contempt, legal experts say.
The case has become a key element in the confrontation between the president and government, on one side, and the Supreme Court and the military on the other. It has plunged the country into crisis and could lead to either a military coup or an early election.
The court was so crowded that visitors needed passes to watch the proceedings.
Ministers from Gilani’s People’s Party (PPP) and the Awami National Party, which is part of the ruling coalition, accompanied him in a show of solidarity but the Pakistani press reports that there were no members of another coalition partner, the Karachi-based Muttahida Qaumi Movement (MQM) present.
There could be more trouble for the government on 24 January.
The man at the centre of the Memogate scandal has been granted a visa by the Pakistani embassy in Bern, Switzerland, according to his lawyer, and is expected to arrive on that day to give evidence at the Supreme Court in that case.
Pakistani-American businessman Mansoor Ijaz claims to have been asked to pass on a memo asking for US help in the event of a military coup.
He claims to have been threatened by the government and will be provided with security by the army.
Former president Pervez Musharraf, however, may delay his planned return from self-imposed exile because the authorities say he would be arrested.
“His friends and party officials want him to postpone it for some time,” Mohammad Amjad, the senior vice-president of Musharraf’s newly founded All Pakistan Muslim League told the AFP news agency.