KABUL, Afghanistan — At a critical stage of Afghanistan’s long war, President Ashraf Ghani on Sunday appointed two staunch anti-Taliban veterans to head the country’s army and police forces, a major shake-up of the security leadership.

Mr. Ghani chose Assadullah Khalid as the minister of defense and Amrullah Saleh as the minister of interior. Both men, close allies of the United States military, are former spy chiefs who have been vocal critics of Mr. Ghani’s politics and what they have described as his government’s mismanagement of the war.

The decision comes at a time when the Afghan army and police have been dying in record numbers in the face of a resurgent Taliban and as President Trump reportedly plans to cut in half the number of American troops advising and assisting the Afghan forces.

The United States is also urgently pushing for a negotiated peace with the Taliban, and the Afghan government — which has felt marginalized in the process — is eager to show that it can sustain military pressure, strengthening its hand in any talks.