At a separate hearing, the top court also took on the country's powerful army, demanding that two military intelligence agencies explain why they held seven suspected militants for 18 months in allegedly harsh conditions without charging them.
Prime Minister Yousuf Raza Gilani pleaded not guilty to the contempt charge. If convicted, he could be imprisoned and will likely lose his job. But analysts said the premier seems willing to sacrifice himself for the benefit of his party and his political ally, President Asif Ali Zardari.
Gilani's ouster would not topple the government. But the case has distracted officials from dealing with a host of ills facing the nuclear-armed country, including a stuttering economy and a vicious insurgency.
The political turmoil has also been a problem for the United States because it wants Pakistan to focus on repairing troubled bilateral relations and help negotiate peace with the Taliban in Afghanistan.
Gilani drove himself and his lawyer to court, an apparent attempt to show humility to the judges. Security was tight, with helicopters buzzing through the rainy, overcast sky and hundreds of police blocking roads leading to the court building in the capital, Islamabad.
One of the judges, Nasirul Mulk, read out the contempt charge, saying Gilani had “willfully flouted, disregarded and disobeyed the direction given by this court.”
The prime minister, who was surrounded by his Cabinet members and coalition partners, said he understood the charge and would contest it. The move was the formal start to a process that will take months or weeks to conclude. The next session will be on Feb. 22.
Court supporters have applauded the judges for upholding the rule of law. But government loyalists accuse the chief justice of pursuing a personal vendetta against president.
The case against Zardari relates to kickbacks he and his late wife, former Prime Minister Benazir Bhutto, allegedly received from Swiss companies when Bhutto was in power in the 1990s. They were found guilty in absentia in a Swiss court in 2003.
Zardari appealed, but Swiss prosecutors dropped the case after the Pakistani parliament passed an ordinance giving the president and others immunity from old corruption cases that many agreed were politically motivated.
The bill was decried by many in Pakistan, who saw it as an attempt to subvert the law. The Supreme Court ruled it unconstitutional in 2009, and also ordered the government to write a letter to Swiss authorities requesting they reopen the case. The government has refused, saying the president enjoys immunity from prosecution while in office.
Analysts said Gilani seems unlikely to bend to the court's demands and will likely be convicted and lose his job. The national assembly would then vote for a new prime minister, but the process could drag for months.
Most legal experts think the president would be in no immediate danger even if Gilani did ask Swiss authorities to reopen the case.
Last year, a Swiss prosecutor told the media that Geneva couldn't bring proceedings against Zardari because he has immunity as a head of state.
But the government may be concerned that the court may question the president's immunity if Gilani agrees to write the letter because of bad blood between Zardari and Chief Justice Iftikar Mohammad Chaudry.
Zardari refused to reinstate Chaudry for many months after he was fired by former President Gen. Pervez Musharraf, despite having promised to do so. He was eventually forced to relent after public demonstrations.
The government's goal seems to be to survive through at least the summer, when it would finish the next annual budget. That would allow the ruling Pakistan People's Party to funnel dollars to the right places to improve its chances in national elections, which are scheduled for 2013 but which many expect could be called early in the fall.
Some government supporters have accused the Supreme Court of acting on behalf of the army to oust Zardari. But no evidence has surfaced to support that allegation, and the court has hounded the military as well.
The court had ordered the country's most powerful spy service, the ISI, to produce seven suspected militants before the judges on Monday. The suspects were held by ISI and another military intelligence agency without charges since 2010.
The order was in response to petitions from the families of the men, who had been looking for them. The relatives claim the men were held in harsh conditions with very little food or water.
Two of the suspects appeared in poor health, with one of them forced to use a urine bag. Four other men who were picked up with the seven had died under mysterious circumstances.
The court gave the spy agencies until March 1 to submit a report, said Pakistan's attorney general, Anwarul Haq. It also instructed officials to arrange medical checkups for the suspects.
The case could have wide-ranging repercussions because the security services are alleged to have picked up hundreds of people over the years and held them without charges.
However, it is unclear if the Supreme Court has the power to hold the army -- the strongest institution in the country -- to account.