Image caption Mr Gilani's remarks have incensed military leaders

Pakistan's military has publicly rebuked Prime Minister Yousuf Raza Gilani over an escalating row.

The army warned of "serious ramifications with potentially grievous consequences" after the PM criticised military leaders in a media interview.

Meanwhile, Mr Gilani has sacked his defence secretary, who is seen as having close ties to the military.

Tensions have been rising in recent months between Pakistan's civilian government and military leaders.

The latest row is a serious source of instability in Pakistan, where the military has ruled for more than half the country's history after seizing power in a series of coups.

'Unconstitutional'

On Monday Mr Gilani was quoted telling China's People's Daily Online that Pakistan's army chief and head of intelligence acted unconstitutionally by making submissions to a Supreme Court inquiry which has been rocking the government.

Analysis What we are seeing is almost unprecedented in Pakistan. The army usually operates behind the scenes - its statement is being seen as another step towards a confrontation with the government. The military has a history of seizing power - but for the first time it is engaged in a media war instead. Pakistan's unbridled free press is one reason why most observers feel the military would be reluctant to stage a coup right now. Added to that are still fresh memories of protests against the last military ruler, Pervez Musharraf. International sanctions which would follow any coup would also do further damage to an already devastated economy. With elections approaching, the civilian government feels under siege on all sides. It hopes to win support by being seen to rein in the military - something that has never been done in Pakistan's history. Ominous turf war in Pakistan

The interview was broadcast as Pakistan's army chief Gen Ashfaq Kayani was visiting China.

On Wednesday, the military hit back with an unusually strongly-worded statement.

"There can be no allegation more serious than what the honourable prime minister has levelled.

"This has very serious ramifications with potentially grievous consequences for the country," the statement said, without specifying what these might be.

It said the prime minister had accused the army chief and the head of Inter-Services Intelligence of violating the constitution.

The army said Gen Kayani had "followed the book" and had passed its response via the defence ministry to the Supreme Court according to the law.

"Allegiance to state and the constitution is and will always remain [his] prime consideration."

The sacking of the defence secretary, retired general Naeem Khalid Lodhi, is likely to heighten frictions with military leaders.

A senior official told AFP news agency that Gen Lodhi had been removed from his post for gross misconduct.

Gen Lodhi recently wrote to the Supreme Court saying the government had administrative, but not operational, control of the army. State media said he lost his job "for creating misunderstanding between state institutions".

Last month Mr Gilani said conspirators were plotting to bring down his government, without specifically blaming the military. That prompted Gen Kayani to dismiss coup rumours.

'Memogate'

Relations between the government and the military have seriously deteriorated in recent weeks.

The Supreme Court is investigating an anonymous memo which sought US help to avert a possible military coup in Pakistan following the killing by US forces of al-Qaeda leader Osama Bin Laden in May.

Image caption The military are Pakistan's most powerful institution

It is not clear who wrote the memo or conveyed it to the Americans. They say they received it but took no action.

Pakistan's military - deeply humiliated by the discovery of Bin Laden on Pakistani soil and the secret US operation to kill him - has been incensed by the affair.

The scandal has already cost Pakistan's former ambassador to Washington, Husain Haqqani, his job. He denies any role in the memo, as does President Asif Ali Zardari.

Mr Zardari could be forced to quit if the trail is found to lead to his door.

The government is also on a collision course with the judiciary, which wants to reopen old corruption cases in which the president argues he is innocent.