WASHINGTON—Former Defense Secretary Robert Gates compiled a pointed critique of President Barack Obama's oversight of the Afghanistan war in a new memoir that exposes strains within the administration over a vital period for U.S. military strategy.

Mr. Gates writes that the president lost faith in the very war strategy he approved, wanted most to find a way out of combat, soured on his handpicked commander and tried to micromanage...