FORT BRAGG, N.C. — An apparent security lapse enabled a convicted murderer to access Sgt. Bowe Bergdahl’s sentencing hearing last week where the individual made threatening remarks about the former Taliban prisoner, who has pleaded guilty to desertion and misbehavior before the enemy.

George Marecek, 85, was only a few feet from Bergdahl on Wednesday when he turned to another individual seated in the courtroom gallery and said: “I’ll be glad when this crap is over. I got my firing squad standing by.” Marecek’s comment was overheard by a Washington Post reporter. Bergdahl’s attorneys overheard Marecek make other threatening statements and alerted the prosecution, who in turn notified authorities.

The Army has refused to answer questions about the incident, which alarmed court officers and triggered a security alert at this sprawling military complex outside of Fayetteville, N.C., according to three people with direct knowledge of the matter. They spoke on the condition of anonymity citing the extreme sensitivity surrounding Bergdahl’s legal proceedings.

Bergdahl, 31, faces life in prison, having pleaded guilty earlier this month to charges that stem from his 2009 disappearance in Afghanistan. He was captured by the Taliban and held hostage for five years, routinely enduring torture before his release was secured as part of a controversial prisoner exchange in 2014.

The sentencing hearing began Oct. 23 with a motion from Bergdahl’s attorneys to dismiss the case. They argue that President Trump improperly used his position as commander in chief to interfere in the process when he referred back to inflammatory statements he made during the presidential campaign. Trump, at the time, called Bergdahl “a dirty, rotten traitor” and suggested he should be executed. The judge, Army Col. Jeffery R. Nance, is yet to rule on the motion.

Marecek, a retired Army colonel, is a highly decorated Green Beret whose bravery during the Vietnam War earned him a Distinguished Service Cross and Silver Star, prestigious valor awards that rank second and third, respectively, behind only the Medal of Honor. Decades later, in 2000, he was convicted of second-degree murder and sentenced to 30 years in prison for killing his wife in 1991. Marecek spent three years at a state correctional facility before earning an early release in 2003.

Marecek did not respond to a phone message seeking comment.

On Wednesday, he arrived at Fort Bragg wearing an Army combat uniform outfitted with his rank and Special Forces insignia. In the courtroom he clutched a tightly shaped green beret. It was after the court adjourned, and Marecek had departed, that prosecutors learned about the incident and alerted security, according to a person familiar with the proceedings.

A spokesman for Fort Bragg refused to discuss the matter, confirming only there had been an unspecified “incident” during Wednesday’s proceedings. Army officials at the Pentagon referred The Post to Army Forces Command, which is coordinating Bergdahl’s legal proceedings. Officials there also refused to discuss the matter.

Army Sgt. Bowe Bergdahl, center, is escorted into the courthouse during his sentencing hearing at Fort Bragg, N.C., on Oct. 16. (REUTERS/Jonathan Drake)

Bergdahl is escorted to and from the courthouse by at least one armed policeman, with others in the immediate area. But Marecek’s threatening remarks, and his ability to access the base despite his criminal history, raise questions about the Army’s security measures for the high-profile trial.

Those attending the proceedings must pass through metal detectors and face additional scans from military police via handheld metal detector wands. The media’s movement also is tightly controlled.

Marecek, as a military retiree, can access the base and park his car in front of the courthouse, presenting just his ID card. While those visiting Fort Bragg should have their identification cards electronically scanned and run through a criminal records database, a former military police officer at the base told The Post that the ID scanners often don’t function properly, so the gate guards simply check to ensure the ID cards have not expired.

Nance informed the court Thursday that authorities were notified after someone made troubling remarks from the gallery during the prior day’s proceedings.

Fort Bragg’s military police unit issued a “be on the lookout” alert, but it does not appear authorities are actively searching for Marecek. One soldier familiar with the trial’s security operation said military police were instructed to question him if he returns. The Army has not asked local police or the U.S. Marshals Service for help finding Marecek, officials with those agencies said.

Bergdahl’s case has sparked a bitter debate within the military and throughout the country between those who believe he endangered the lives of fellow service members tasked with finding him and those who feel his years in captivity are sufficient punishment for his offenses.

Speaking to reporters earlier this month, the president declined to say whether his previous attacks on Bergdahl may have unfairly influenced the soldier’s decision to plead guilty. “But,” he added, “I think people have heard my comments in the past.”

In court last week, Nance explained that his interpretation of Trump’s meaning was, “I shouldn’t comment on that, but I think everyone knows what I think about Bowe Bergdahl.”

Bergdahl’s lawyers have seized on Trump’s remarks to argue that the case should be dismissed.