ISLAMABAD (AP) ' Pakistan's top court rejected Friday a last-ditch appeal filed by the prime minister against a looming contempt charge, paving the way for a case that could plunge the nuclear-armed country into political turmoil.

The Supreme Court is demanding that Prime Minister Yousuf Raza Gilani reopen corruption proceedings against President Asif Ali Zardari. Gilani is refusing, arguing that Zardari, who also heads the ruling party of which the prime minister is a member, has immunity from prosecution while in office.

Last week, the court ruled that Gilani would be charged with contempt next Monday.

His lawyer appealed the decision but Chief Justice Iftikar Mohammad Chaudry rejected the petition on Friday.

Gilani could be sentenced to prison for six months and lose his job if found guilty of contempt. This would likely be a drawn out process that could last months. If Gilani refuses to obey the court, some analysts have speculated the army could be called into to ensure the judges are obeyed.

The graft case against Zardari relates to kickbacks that he and his late wife, former Prime Minister Benazir Bhutto, allegedly received from Swiss companies when Bhutto was in power. They were found guilty in absentia in a Swiss court in 2003.

Zardari appealed, but Swiss prosecutors ended up dropping the case after the Pakistani parliament passed a bill giving the president and others immunity from old corruption cases that many agreed were politically motivated.

Since January, the case has consumed Pakistan's highly polarized political and media elite, deflecting attention from what many say are existential threats to the country like an ailing economy and a violent Islamist insurgency that is showing little sign of ebbing.

Relations between Islamabad and a vital donor, the United States, are at a low ebb after U.S. aircraft killed 24 Pakistani soldiers on the Afghan border last November, prompting Pakistan to close its border to U.S. and NATO supplies heading for Afghanistan.