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.

One of the officers, Maj. Gen. Charles Gurganus, the former top commander in Helmand province, had been nominated for a third star and a top job on the Marine Corps staff. Gen. Gurganus's nomination had been on hold, and will now be withdrawn. The second, Maj. Gen. Gregg Sturdevant, who commanded the Marine aviation arm, is currently serving on the staff of the Pacific Command.

The investigation by U.S. Central Command, which oversees American forces in Afghanistan, determined that the insurgents cut a hole in a fence near an unmanned guard tower on Sept. 14, 2012, then snuck into the base. The insurgents were able to roll grenades under fighter planes, badly damaging the Harriers, according to the investigation report, which said destroying aircraft was the primary objective of the attackers.

Prince Harry of Wales, a member of the British royal family, was serving as a helicopter pilot on the base at the time of the attack, investigators said. But they said that the insurgents were not targeting him and that British forces had not reduced perimeter security to more closely protect the prince, according to the report.

The Central Command report said that Gen. Gurganus underestimated the enemy's capabilities, overestimated U.S. capabilities and "failed to take prudent steps to counter or mitigate an enemy attack." Gen. Sturdevant, the report concluded, improperly relied on other units for the defense of his aircraft and troops.

Gen. Amos said that both men were serving under difficult anddangerous conditions, working under orders to drastically draw down the size of the Marine force while continuing to train Afghans and fight Taliban militants.

In the months before the attack, Gen. Gurganus had requested reinforcements to improve the defenses of his base, a request that was denied as commanders worked to bring down the number of Americans in Afghanistan under orders from the Obama administration.

Gen. Amos said it was Gen. Gurganus's responsibility to shore up defenses, even if his request for more troops was denied. But he said future commanders shouldn't take from the disciplinary action the lesson that force protection is more important than accomplishing an overall mission.

"I don't want commanders to wring their hands and take the wrong message here," Gen. Amos said.

In a statement, Gen. Gurganus said it had been an honor to serve in the Marines and that he fully respected Gen. Amos's decision. "I have complete trust and confidence in the leadership of our Corps," he said.

In a statement, Gen. Sturdevant also said he respected Gen. Amos's decision. "Forever I will always be proud to be a United States Marine," he said. "The Marines I have had the honor to serve with have always inspired me."

Family members of the two men killed in the attack, Lt. Col. Christopher Raible and Sgt. Bradley Atwell, had criticized the defenses at the base.

In a statement, Donnella Raible, the widow of Lt. Col. Raible who has spoken critically about the base defenses, said she was grateful for the review. " I…am satisfied to know the Marine Corps is holding those accountable who did not meet the standards and professional judgment expected of a commander in combat," she said.

While backing the families' overall critique that the defenses at the base were inadequate, investigators rebutted some specific allegations, noting, for example, there was no evidence that guards were sleeping in the towers.

But Gen. Amos said that Gen. Gurganus failed to properly assess the risk that insurgents could breach the perimeter of the base. He said that Gen. Sturdevant failed to create a layered defense inside the base that could have supplemented British defenses.