Pakistani Prime Minister Yousuf Raza Gilani waves upon his arrival at the Supreme Court in Islamabad, Pakistan, on Thursday. (B.K.Bangash/AP)

Pakistan’s Supreme Court on Thursday granted the prime minister two weeks to prepare his defense on contempt of court charges, prolonging a political crisis that has shaken this nuclear-armed nation and set off a frenzy of media coverage.

Prime Minister Yousuf Raza Gilani appeared in court to explain why he has not pursued long-standing corruption allegations against President Asif Ali Zardari, something the court has repeatedly ordered and the government has repeatedly refused to do. The testimony capped days of speculation about whether Gilani would apologize, agree to the court’s demands or resign — and about the implications for a civilian government facing collapse amid duels with the military and the judiciary.

Instead, Gilani stuck to the government’s position that Zardari is immune from prosecution, and his recently appointed attorney, Aitzaz Ahsan, pleaded for more time to study the case. The court consented and set the next hearing for Feb. 1, when Gilani’s attorneys are expected to delineate why the prime minister is not guilty of contempt of court and formally argue, for the first time, the case for Zardari’s immunity.

The court move marked another abrupt development in a building drama that has been punctuated by displays of cooperation between rival power centers. As rumors of a possible military coup swirled last week after the army and Gilani traded barbs, Zardari and the army chief met, briefly easing the sense of impending calamity.

That apprehension returned Thursday morning, with security helicopters hovering in stormy skies above the imposing court building here as Gilani arrived, driving himself.

In a 20-minute address to the court, Gilani again insisted that Pakistan’s constitution confers immunity on Zardari and that he respects the court — a claim questioned by one justice, who asked why the government had ignored its orders.

Ahsan, Gilani’s lawyer, told reporters after the hearing that the prime minister’s rare appearance in court represented a “very important day in our judicial history.”

Ahsan’s appointment this week was viewed as a shrewd move that helps the government deflect charges it has flouted the rule of law. Ahsan, a longtime stalwart of the ruling Pakistan People’s Party, or PPP, was also a prominent figure in the lawyers’ street movement that helped bring down the military government of Gen. Pervez Musharraf in 2008 and reinstate the current Supreme Court chief justice, Iftikhar Mohammed Chaudhry, whom Musharraf had fired.

The legal community has since splintered, however, and in a measure of acrimony over the present political situation, crews of lawyers chanted anti-government slogans as Ahsan spoke to reporters. “Return the looted wealth!” went one chant, referring to Zardari’s alleged misdeeds.

“We see the frustration among the masses growing,” S.M. Zafar, a prominent lawyer, told the Geo television network. “The position of the government is well known, so this [postponement] of two weeks is too much.”

The postponement is likely to cool the political fever only temporarily. The standoff will resume at the next hearing, when the court could convict Gilani or issue other rulings that could imperil the government.

The Zardari corruption case is rooted in a money-laundering investigation by Swiss authorities, who dropped their probe after a 2007 Pakistani amnesty measure invalidated criminal cases against the president and hundreds of other politicians.

That amnesty was overturned in 2009, and the Supreme Court has ordered the government to write a letter to Swiss prosecutors that would essentially authorize them to reopen their probe. The Swiss have shown little inclination to do that, and Ahsan said this week that there would be “no harm” to Zardari if the letter were sent.

The corruption case is one of two legal matters that have brought the government into open conflict with the Supreme Court. Ruling party supporters and some analysts say the court has pursued the government with uncommon zeal and is spurred by the military, which has made little secret of its distaste for Zardari and his unpopular government.

A Supreme Court panel is also investigating an unsigned memo given to the Pentagon after the killing of Osama bin Laden last spring. The document promised pro-U.S. security reforms in exchange for assistance thwarting a possible military coup. The army, which remains the central axis of power in Pakistan, believes the memo originated in Zardari’s circles and has urged the court probe. The government says it has no connection to the memo and has suggested that the whole affair is a setup.

Both court probes endanger the government, which aspires to be the first in Pakistan’s history to complete its term by making it to general elections in 2013. Opposition parties would prefer that the government collapses before scheduled Senate elections in March, when the PPP is expected to secure a majority.