Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The Army will not discharge a Green Beret who beat up an Afghan police commander for raping a boy, a reversal that followed allegations that U.S. troops have been discouraged from intervening in sexual abuse among locals.

The Army Board for Correction of Military Records confirmed to NBC News Friday that Sgt. 1st Class Charles Martland would be taken off a list of officers to be removed from service. That means he will be allowed to stay in the Army, the board said in a statement.

Sgt. First Class Charles Martland via Office of Rep. Duncan Hunter

The Army did not explain why it changed course, but the board's statement suggested that it had to do with a technicality in the negative evaluations Martland received after the September 2011 incident.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

A spokesman for California Rep. Duncan Hunter, who championed Martland's cause, said his office found "irregularities" in the disciplinary process.

"We were under no illusions that the Army would stand up and say Charles was right to tune up that child molester," the spokesman, Joe Kasper, said.

The larger issue — how the military handles allegations of child sex abuse by Afghan authorities — remains under scrutiny. The Pentagon's inspector general is investigating it. And the Afghan government has said it would work harder to prevent the sex abuse of children by its military and police.

U.S. military commanders have denied that service members have ignored sex assault. But they have said the problem is largely one to be tackled by Afghan authorities.

But as Martland's case shows, the reality is far murkier — particularly as the United States continues to train and assist Afghan forces in their fight against the Taliban.

RELATED: Afghanistan Vows to Stop 'Inhuman' Child Sex Abuse

Martland has admitted that he and a supervisor were "absolutely wrong" to hit the Afghan Local Police commander while deployed in Kunduz Province. But he said they were moved to act after the commander kidnapped and raped a local boy, and beat the boy's mother for seeking the Americans' help.

"We already had two other ALP commanders receive no punishment from the Afghan government for the rape of a 15-year-old girl and the honor killing of a commander's 12-year-old daughter for kissing a boy," Martland wrote in a January 2015 memo that Hunter's office provided to NBC News. "My Detachment Commander and I felt that morally we could no longer stand by and allow our ALP to commit atrocities."

Martland and his supervisor, Capt. Dan Quinn, were pulled from Afghanistan. Quinn left the military, while Martland fought his punishment. He eventually turned to Hunter, a former Marine, who fought Martland's removal and drafted a bill that would allow U.S. troops to confront sexual abuse.

"I believe SFC Martland and his team should be commended for showing any restraint at all," Hunter wrote to Department of Defense Ash Carter in August. "And they most certainly had a moral obligation to intervene."