WASHINGTON—The Marine Corps commandant on Monday ordered two high-ranking generals to leave the service as a result of their failure to put in place adequate defenses at a key base in Afghanistan, a rare instance of the military punishing senior officers for wartime lapses.

In an attack last year on Camp Bastion, a joint U.S-British and Afghan base in Helmand province in Afghanistan, 15 insurgents killed two Marines, wounded eight other Americans and eight British troops. The attackers also destroyed six Harrier fighter jets and damaged other aircraft.

The attack led Gen. James Amos, the Marine commandant, to request the retirement of the two major generals. It was considered an unusual step even for Gen. Amos, who has been particularly aggressive about pushing officers out of command if their performance has been found lacking.

"Commandership is a sacred responsibility, and standards for general officers are necessarily high," Gen. Amos said in a meeting with reporters. "In their duty to protect our forces, these two generals did not meet that standard."

Other senior officers who served during the Iraq and Afghanistan wars have retired in the aftermath of questions surrounding insurgent attacks. But those retirements generally came after senators blocked their confirmation for promotion, not as a result of a public reprimand by top military leaders.