The heads of Brazil’s army, navy and air force resigned Tuesday, rocking a right-wing government that is already facing public fury over President Jair Bolsonaro’s inability to contain the fast-spreading coronavirus pandemic. Brazil’s Defense Ministry said the three commanders would be substituted, without giving further information. A person close to the ministry said the men had stepped down.

The announcement came a day after Mr. Bolsonaro replaced six of his cabinet members, including a surprise move to dismiss the defense minister. Political analysts said the firing of Fernando Azevedo e Silva, a former army general widely respected within the military, likely sparked the exit of army chief Edson Pujol, navy head Ilques Barbosa and air force chief Antônio Carlos Moretti Bermudez.

Mr. Bolsonaro has faced bitter criticism over his handling of the pandemic, which has killed more than 314,000 people here. With a new, more infectious variant of the coronavirus spreading, roughly 100 Brazilians are dying from the disease every hour, the highest death toll anywhere in the world.

Tensions between the military and Mr. Bolsonaro, a former right-wing army captain who served under Brazil’s 1964-85 dictatorship, have risen in recent months as the president has increasingly called on the armed forces to back him politically.

“Bolsonaro sees the armed forces as subordinates of the government but the armed forces consider themselves subordinates of the constitution,” said Thiago de Aragão, a Brasília-based political consultant.

Leading centrist and leftist politicians came out in support of the former military chiefs Tuesday, saying their departures marked a step backward for Brazilian democracy.

“As if the pandemic and the difficult economic situation were not enough, now there is concern among military chiefs,” said former President Fernando Henrique Cardoso, a centrist. “I hope the armed forces remain loyal to the constitution.”

Some politicians accuse Mr. Bolsonaro of willful negligence during the pandemic. Guilherme Boulos, a leading leftist politician, said he wants to marshal support in congress to remove the president. “Congress has to start impeachment proceedings against him immediately to save lives and our democracy,” said Mr. Boulos.