The Marine’s wrists and ankles were shackled Thursday night as two officers escorted him down a long hallway toward the car that would take him to his cell.

Maj. Mark Thompson had finally admitted he’d been lying for years about a sexual misconduct case.

Standing in his khaki uniform earlier that day, Thompson faced a military judge in a courtroom at Marine Corps Base Quantico and pleaded guilty to charges of making a false statement and of conduct unbecoming an officer and a gentleman. For his crimes, Thompson was expelled from the Corps he’d served for two decades and sentenced to 90 days’ confinement.

“I should have faced the entire truth,” he said, his voice soft but forceful. “I’m exhausted, broken in spirit and ready to pay what I owe.”

The dramatic day marked the end of a six-year saga for Thompson that offered a lesson in the consequences of hubris. For years, he had fought to prove he was innocent of a crime — having sex with two young women while they were students at the Naval Academy — that he knew he had committed.

Maj. Mark Thompson slumps in the back of the car taking him to his cell after the former Naval Academy teacher was sentenced to 90 days’ confinement and dismissal from the Marine Corps. (J. Lawler Duggan/For The Washington Post)

At times tearful, he neither looked nor sounded anything like the once-audacious combat veteran who had always been willing to take risks, confident that he could maneuver through even the most perilous situations: He’d had at least two threesomes involving students while teaching at the renowned Annapolis campus. He had stood by as a friend and fellow Marine, Maj. Michael Pretus, lied for him at his first trial. And he himself had lied under oath to an administrative board deciding whether he should be booted from the Marine Corps.

But after all of that — after being convicted of sexual misconduct and still managing to save his career and a generous pension — it still wasn’t enough. Desperate for exoneration, Thompson brought his story to The Washington Post in late 2014, a decision that would ultimately lead him to the courtroom this week.

“He was on an obsession course. You couldn’t get him to talk about anything else,” said Pretus, whose own career was derailed by the case, told Marine investigators last year.

As part of his plea deal, Thompson’s punitive discharge will be suspended, allowing him to collect retirement benefits if he meets the terms of the agreement. But his retirement will be reviewed by the Navy Secretary, who could decide to demote Thompson and dramatically reduce his pension.

The defense had argued that Thompson, 47, should be allowed to retire voluntarily. Lt. Clay Bridges blamed his client’s behavior on unresolved emotional turmoil that followed a series of personal tragedies, including the death of his fiancee in a 2006 car accident.

“He couldn’t control the anger and grief and took it out in a completely inappropriate way,” said Bridges, who urged the judge, Lt. Col. Christopher Greer, to consider the Marine’s entire career, including deployments to Iraq and Afghanistan.

Earlier, the prosecution had portrayed Thompson as far more calculating, playing an audio clip from an interview a Post reporter conducted with the Marine. In it, Thompson emphatically and repeatedly denied that he’d had sex with the two women.

His lies were “bold and unequivocal,” Capt. Conor Lamb said.

“This wasn’t a mistake. This wasn’t a moment of panic. He was trying to sell his story.”

One of the women, Sarah Stadler, wrote the court a letter describing the devastating impact he’d had on her.

“This was a deliberate decision to try to destroy the lives of other people, including mine, by perpetuating lies, just to satisfy his vanity and prove how clever he was,” she wrote.

“Instead of letting sleeping dogs lie, he pursued a calculated plan to try to rehabilitate himself at the expense of others and at the expense of the truth.”

What led Thompson to Thursday’s plea hearing began in 2011, when — amid a drunken night of strip poker at his Annapolis home — he had sex with two female midshipmen, including Stadler. She testified that she and Thompson had been in an ongoing relationship. The other woman told the court that she’d been raped.

At his court-martial in 2013, a jury acquitted him of the sexual assault charge but still found him guilty of five lesser offenses, including conduct unbecoming an officer, indecent conduct and fraternization. He was sentenced to serve two months in a military prison and fined $60,000, though his jurors stopped short of kicking him out of the service.

The next year, he faced an administrative board that would decide his fate in the service and, for the first time, he testified on his own behalf. Thompson insisted to the three officers overseeing the case that he was innocent.

They believed him.

In a stunning decision, the board members declared in a 2-to-1 vote that he had committed no crimes whatsoever, and all three agreed that he should remain a Marine.

“I beat them,” Thompson texted Pretus the next day.

Emboldened, Thompson asked a friend to approach The Post on his behalf. In repeated interviews, he insisted he had done nothing wrong.

But the discovery of Stadler’s long-missing cellphone changed everything. It contained text exchanges with Thompson that proved he’d deceived the Marine board.

Confronted about why he had misled authorities, he said, “I simply had to, when they were coming after me for 41 years, I can’t begin to say, you know, how terrifying that is.”

After the article was published last March, the Marine Corps launched the investigation that resulted in the new charges against him. He could have faced a prison term of up to six years.

Almost no one involved in Thompson’s case escaped unblemished: The Naval Criminal Investigative Service failed to discover significant pieces of evidence, including Stadler’s cellphone. The case’s lead prosecutor, Aaron Rugh, now an appellate judge, became the subject of an ethics investigation after The Post revealed he’d made false statements to the Marine board; the Navy later cleared him of wrongdoing. And Pretus was removed from his position as a history instructor at the Naval Academy after the school learned he’d been accused of having a tryst with Stadler and Thompson more than five years ago.

At the hearing, a series of relatives, friends and former colleagues described Thompson as a dedicated teacher and father as well as a resourceful, capable military officer.

Donald Wallace, a history professor and Thompson’s mentor at the Academy, said he cautioned his friend to avoid getting too close to female midshipmen.

“I wish he had made different choices,” Wallace said. “I wish things had gone differently.”