ISLAMABAD, Pakistan â€” Prime Minister Yousaf Raza Gilani fired his defense secretary, a retired general and confidant of Pakistanâ€™s army chief, on Wednesday as the civilian government drew closer to a head-on collision with the countryâ€™s powerful military leadership.

Mr. Gilani accused the secretary of defense, Naeem Khalid Lodhi, a former corps commander, of â€œgross misconduct and illegal actionâ€ and of â€œcreating misunderstanding between the state institutions.â€ He replaced the former general with a civilian aide, Nargis Sethi.

Military officials warned on Wednesday evening that the army would be likely to refuse to work with the newly appointed defense secretary, signaling the possibility of a serious rupture between the army and the civilian government. â€œThe army will not react violently, but it will not cooperate with the new secretary defense,â€ said a military officer, speaking on condition of anonymity because of the delicacy of the situation.

Tensions had intensified between the government of President Asif Ali Zardari and the army leadership after the publication of a controversial memo, purportedly drafted by the government shortly after an American raid last year killed Osama bin Laden, that solicited help in stopping a possible coup by the humiliated Pakistani military.

Gen. Ashfaq Parvez Kayani, the army chief, called an emergency meeting of his top commanders on Thursday.

The defense secretary is ordinarily appointed with the consent of the army chief and acts as a bridge between the civilian government and military. The role is more powerful than that of defense minister, a position that is filled by a politician from the governing party.

The firing came as the military warned the prime minister that his recent statements against General Kayani would have â€œserious ramifications with potentially grievous consequences for the country.â€ Mr. Gilani had accused General Kayani and Lt. Gen. Ahmad Shuja Pasha, the head of Pakistanâ€™s intelligence service, of acting as â€œstate within a stateâ€ and reminded them they were accountable to the Parliament.

Those statements were seen as suggesting that they could be removed from power.

The defense secretaryâ€™s signature is needed for the appointment â€” or termination â€” of the members of the military leadership. By installing a secretary defense of its own choice, the civilian government appeared to be seeking greater leverage in dealing with the military.

Speculation about the governmentâ€™s intentions to dismiss the two commanders were fueled by news reports in the stridently anti-American press in Pakistan, where many people view the United States as an arrogant adversary instead of an ally. That view has increased in the months since the Bin Laden raid last May and the deaths of 26 Pakistani soldiers in an American airstrike near the border with Afghanistan late last year.

Pakistani analysts said the firing of Mr. Lodhi could be a potentially ominous sign that the festering conflict between the army and the civilian government had reached a critical stage.

â€œIt is a desperate measure,â€ said Ikram Sehgal, a defense analyst and former army officer. â€œThey want the army to react and to make a coup.â€

Hasan Askari Rizvi, a military and political analyst, said the firing would only exacerbate the situation for the civilian government. â€œIf the prime minister now tries to fire the army chief, it will have very dangerous consequences,â€ Mr. Rizvi said.

General Lodhi, who was only recently appointed defense secretary, became embroiled in a controversy last month after he submitted a statement in the Supreme Court on behalf of the Defense Ministry stating that the civilian government had no operational control over the Directorate for Inter-Services Intelligence, Pakistanâ€™s powerful spy agency. Mr. Gilani accused Mr. Lodhi of overstepping and objected to his blunt statement, a public acknowledgment that, while the intelligence services are technically under the control of the prime minister, they are widely perceived to act independently of the civilian government.

A military official, who spoke on the condition of anonymity because he was not authorized to speak publicly, said that the relationship between the two men broke down after the prime ministerâ€™s staff sought to pressure General Lodhi into contradicting statements by the army and spy chiefs about the controversial memo. The military commanders had told Supreme Court last month that the memo, written by a former ambassador to the United States, Husain Haqqani, was authentic and pointed to a conspiracy against the military. The government and Mr. Haqqani have said they had nothing to do with the memo, which came to light in October.

â€œThe government had prepared a draft that stated that the Ministry of Defense does not agree with General Kayani and Genera Pashaâ€™s opinions about the veracity of the memo,â€ said the military official, who was present during the discussions. â€œGeneral Lodhi refused to sign the document, saying those were not his words.â€