A Marine veteran who fought the Pentagon for 12 years over a war-crimes case brought against him and six others will have his permanent record wiped clean, an extraordinary affirmation of his claim that their reputations were destroyed by the military’s effort to imprison the men.

The Marines were members of an elite commando force expelled from Afghanistan in 2007 amid unproven allegations that they massacred innocent bystanders in the frantic minutes following an ambush. They were cleared of wrongdoing more than a year later, after the case was heard by a military court, but have maintained that senior leaders did little to set the record straight and, consequently, fostered the stigma that has dogged them ever since.

A report approved in January by the Navy Department is a major victory for retired Maj. Fred Galvin, the Marines’ commanding officer. Its conclusions, he says, are a rebuke of those who condemned his men before the facts were clear, the investigator whose work was shown in court to be sloppy and the generals who refused Galvin’s pleas for public absolution.

In its ruling, the Board for Correction of Naval Records said Galvin, 49, should be considered for a retroactive promotion. If granted, he would be entitled to hundreds of thousands of dollars in back salary and future government pension benefits, as he was forced to retire in 2014 after his superiors relied on “inequitable and unjust” performance appraisals, the report states, to prevent him from advancing in rank. Of the seven swept up in the case, Galvin is the only one to pursue such vindication.

More broadly, the board’s determination closes one of the Afghanistan war’s darkest chapters, an episode that unleashed international outrage only to be proved a fabrication engineered by the Taliban to fuel distrust of the U.S. military. Those involved fought for their lives that day only to be denounced by senior officers who had an obligation to protect their presumption of innocence.

“This was a big betrayal,” said Steve Morgan, a retired Marine officer and decorated combat veteran who in 2008 was part of the court panel that found Galvin’s Marines acted honorably on the battlefield. The panel also memorialized the failures committed by the Marines’ superiors during and after the investigation.

“Fred has finally come out on the right side of things, but it has come at a very steep price,” Morgan added. “The lies. The deceit. That makes me so mad. That kind of behavior doesn’t inspire confidence in the ethics of our military’s leaders. It corrodes public trust in the institution.”

Galvin was the commanding officer of Marine Special Operations Company Fox. On March 4, 2007, as he and 29 others traveled in a six-vehicle convoy through the village of Bati Kot, a suicide bomber driving a van packed with explosives attacked the American vehicles and then fighters on both sides of the road opened fire. The Marines fought back and escaped with only one minor casualty.

But in the fight’s immediate aftermath, images of bullet-riddled vehicles and ambulances loading bloodied Afghan men were transmitted worldwide. Accounts gathered at the scene portrayed the Marines as murderers, and allegations of wrongdoing were fueled by erroneous media coverage and a bogus narrative fostered by American military officials who fed false information to news outlets, the court’s conclusions would later make clear.

Galvin harbors resentment for many, peers and superiors alike. “That 12-page report is an indictment,” he said. “It shows the decay of ethical and moral leadership in our military. And the people who did this to us got a free pass.”

Chief among his adversaries is John W. Nicholson Jr., who retired from the Army last year after ascending to the rank of four-star general and serving for 2 1 / 2 years as the head of all NATO forces in Afghanistan. When the incident occurred, Nicholson was a colonel and brigade commander overseeing operations in the area, along the mountainous span of Afghanistan’s border with Pakistan that was thought to be harboring al-Qaeda leader Osama bin Laden.

Francis H. Kearney III, then a two-star Army general with purview of covert Special Operations activity in Afghanistan and throughout the Middle East, dispatched his chief of staff, Patrick Pihana, to investigate.

Independent assessments of the casualty count varied widely. Amid widespread protests in Afghanistan, Hamid Karzai, the country’s president at the time, condemned the Marines. Hoping to contain the backlash, Nicholson broadcast an apologetic statement declaring the incident a “stain” on the U.S. military’s honor.

Privately, officials were suspicious of the unit because of a separate incident involving Galvin’s men in which, days after the ambush, they deceived him and other leaders to undertake a mission in an area declared off limits. Commanders in Afghanistan, still riled by the allegations of indiscriminate killing, pointed to the Marines’ duplicity as evidence that Galvin had lost control of his unit. He was relieved of command and Fox Company was sent home.

The Navy review board sided with Galvin here, too, concluding that his superiors “grossly overreacted” and did not differentiate between the two incidents when ordering the Marines to leave.

Nicholson and Kearney, who retired as a three-star general in 2012, are not named in the new report. However, it makes clear that senior U.S. officials made “gross errors in judgment” leading up to Kearney’s decision to eject the Marines from Afghanistan, and that along with the Taliban’s deception, Army leaders were the “proximate causes” for inciting the chain of events that led to that decision.

The report’s harshest language is directed at Pihana, whose investigation, it notes, was discredited in court years ago, in part because he was found to have suppressed evidence that supported the Marines’ version of events — and was suspected by the court of having been influenced by Kearney, his direct superior.

“The magnitude of his errors,” the report says, “cannot be overstated.” Pihana’s conclusion — that Galvin and the others should be charged with negligent homicide or dereliction of duty — is “explicable only as gross negligence or a mission with a predetermined outcome,” the report says.

Neither Nicholson, Kearney nor Pihana responded to requests for comment.

Morgan has urged members of Congress to push the Pentagon to reexamine whether Nicholson, Kearney or Pihana violated military regulations or laws in their pursuit of a criminal case and, if so, to hold them accountable.

“Nicholson and Kearney perpetuated the myth these Marines did bad things, and they’ve done nothing to set the record straight,” Morgan told The Washington Post. “I’ve got no time for those guys.”

In 2015, when Military Times reexamined this case in a multipart series, Kearney said he ordered the investigation at the Marine Corps’ request because, he recalled, there was pressure on the military to demonstrate accountability in light of two unrelated war-crimes cases involving U.S. personnel in Iraq. “If these Marines have heartburn,” he said, “it should be with the Marine Corps.”

It was Jim Mattis, a revered Marine general and recently departed defense secretary, who convened the tribunal that ultimately determined that none of the Marines should be charged. The hearings spanned three weeks in January 2008. Four months later, at the outset of Memorial Day weekend, Mattis’s successor, having assessed the court’s findings, issued a brief statement affirming that Galvin’s men had “acted appropriately.”

That phrase still bothers the Marines, who say it was not a firm enough declaration of their innocence, and that it has been misinterpreted inside and outside the military to mean “we got away with murder,” Galvin said. He also questions the announcement’s timing, calling it a deliberate move to bury the story. As a consequence, those assigned to the unit were ostracized.

“Sometimes now, when I reflect on it, I think that if this didn’t happen, I’d be four years from retirement. I could have stayed in and made that my career,” said one of the Marines who was falsely accused and left the military voluntarily in 2008, when his contract expired. He spoke on the condition of anonymity, citing lingering concerns about retaliation.

“This devastated my life — my family, my legal expenses, being separated from the Marine Corps, not knowing if one day someone was going to knock on my door and take me to Fort Leavenworth,” he added, referring to the Army post in northeast Kansas that is home to the military’s only supermax prison.

The stress — and the shame — has been a burden on all of them, leading to substance abuse, divorce and thoughts of suicide in some cases, Galvin said.

As their former commanding officer, Galvin has continued to press Marine Corps headquarters to do more to set the record straight. Beginning in 2015, with support from five members of Congress, multiple entreaties have been made to the service’s most senior officer: first, to Gen. Joseph F. Dunford Jr., who became chairman of the Joint Chiefs of Staff later that year, and then to Dunford’s successor, Gen. Robert B. Neller.

When approached by lawmakers, Dunford and Neller each declined to revisit the matter or make any public statements of support for the Fox Company Marines. In his correspondence to members of Congress, Dunford restated the court’s findings from years prior, saying that neither Galvin nor his men faced any punitive measures. “Nor is there any adverse information in their military records associated with this incident,” the general noted then, incorrectly.

Galvin grew hopeful when Neller announced in 2016 that he was making suicide prevention a signature focus of his term as the Marine Corps commandant. “We can’t afford to lose a single Marine to anything, whether it be accident, injury or suicide,” Neller told Marine Corps Times then. “I can tell you — giving my solemn word — that the Marine Corps will try to help anyone who comes forward.”

Last February, under pressure from Rep. Walter B. Jones (R-N.C.), Neller’s staff director at the time, Maj. Gen. Frederick M. Padilla, pledged that the service would provide counseling and other assistance to Galvin and his men. “We are concerned to hear of the challenges many members of Fox Company are facing — which are, unfortunately, all too common among our combat veterans,” Padilla wrote to Jones. “I have asked the Commanding Officer of our Wounded Warrior Regiment to follow-up with these Marines to ensure they are receiving appropriate and all necessary care and support.”

No one from the Marine Corps contacted them, Galvin said, until reading about Padilla’s directive in The Post several weeks later.

At the Pentagon, Dunford and Neller have acknowledged the review board’s determination. “General Dunford was pleased to learn about Maj. Galvin’s exoneration and also appreciates his efforts to take care of the Marines from Fox Company,” said Col. Patrick Ryder, a spokesman for the chairman.

Neller said: “We have a system through which Marines can try to remediate actions believed to have been unfair or incorrect. In this case, it seems the system worked as designed, and Maj. Galvin had his record cleared. We all wish him well.”

The Marines hope the military will do more to demonstrate that they are not outcasts but victims. “Military justice requires that those who . . . have conducted wrongdoing be held accountable,” Galvin said, “not just that those offended be patted on the back.”