The leaders of El Salvador's main street gangs have said a decision taken by the Supreme Court threatens a truce that has saved thousands of lives.
The Constitutional Chamber of the Salvadorean Supreme Court declared illegal the appointment of Security Minister David Mungia Payes.
He is one of the main architects of the truce, which was agreed in March 2012.
Gang leaders gave a news conference in jail criticising the court's decision.
The Supreme Court also ruled on Friday that the government must replace the country's police chief, Francisco Salinas.
The court says both jobs must be held by civilians. The two men are army generals.
The decision put the lives of Salvadoreans under risk as it threatened the future of the non-aggression pact agreed last year, the gang leaders said.
But they renewed their commitment to carry on with the ceasefire, provided it was backed by the security authorities.
President Mauricio Funes says he disagrees with the ruling but will accept it.
"I have no doubt that behind the arguments of the court is a very clear anti-military bias," said Mr Funes in his weekly radio address.
He promised to appoint replacements in the next few days.
LA gang culture
Leaders representing the Mara Salvatruchas (or MS-13) and 18 Street gangs said they hoped the new security minister and police chief would support the truce.
MS-13 and the 18 Street gangs were created in the 1980s in Los Angeles in the US by poor, mostly illegal, immigrants who had escaped from the civil war in El Salvador.
When the conflict ended, with a peace treaty signed in 1992, many of those already in jail in the US were expelled and deported to El Salvador, exporting LA's gang culture to Central America.
El Salvador's neighbours, Honduras and Nicaragua, also saw an increase in gang violence.
In March 2012 the two gangs agreed to a ceasefire, mediated by the Catholic Church, which has sharply reduced the number of murders in El Salvador.
Murder rates have dropped dramatically since the gangs agreed to stop killing each other last year, the government says.
The gangs continue operating in several American cities.
Last year, the US Treasury designated MS-13 as a "transnational criminal organisation".