For nearly a decade, Richard Meleski told almost anyone who would listen about the 18 hours he said he spent as a prisoner of war in Beirut in the 1980s.

As the story went, he and his fellow members of Navy SEAL Team Six were captured by hostiles who shattered his hand with a hammer. They executed one of his teammates. And with the body of another slung over his shoulder, he escaped by diving out a window — a feat of valor, he said, that earned him top military honors but left him with injuries and post-traumatic stress that he has struggled with ever since.

As far as everyone in his life was concerned — his long-term girlfriend, his employers, his doctors at the Cpl. Michael J. Crescenz VA Medical Center in Philadelphia — Meleski was a hero.

But not a single word of his story was true.

In fact, he had never served one day in the military. Most of the time he claimed to have been stationed overseas he had actually spent in and out of New Jersey prisons.

Still, Meleski, of Chalfont, used that whopper of a story to bilk the Department of Veterans Affairs out of more than $300,000 in health care between 2010 and 2019. And on Wednesday, he was sentenced to 40 months in prison for it.

“What I see is a 60-year-old pretender who flagrantly scammed the VA at the expense of those who deserve it,” U.S. District Judge Timothy J. Savage told him at the end of the hearing. “A man who lived years in a fantasy.”

Pressed by the judge to explain why, Meleski, slump-shouldered and struggling with his words, offered a shrug and a litany of apologies.

“I guess I wanted to be someone who I wasn’t,” he said, adding later: “To all the veterans, my girlfriend — my ex-girlfriend, I should say — and all the people I caused shame to, I’m so very sorry from the deepest layer of my heart and soul.”

His lawyer, federal public defender Nancy MacEoin, offered more by way of explanation, calling the true story of her client’s life “a pretty sad tale.” Born in Scranton, he had a troubled childhood after his mother died and he moved to New Jersey with his father, an Air Force veteran.

“This is a man,” she said, “who seemingly does not believe that he deserves other people’s affection” without wild stories that make him out to be the hero.

Meleski’s fondness for fabrication became clear in early adulthood.

While working as a volunteer firefighter in New Jersey in the early 1980s, he was convicted of secretly setting fires so that he could later put them out and bask in public acclaim.

A string of other arson convictions followed — including one in 2003 at a Catholic hermitage in Morris County, N.J., where he had been living with a group of nuns. The priest who oversaw the facility said that just before Meleski burned down two of its cottages he had been caught stockpiling altar wine.

It was after his release from prison for that crime that he began spreading tall tales of military valor.

While working as a forklift operator at a warehouse supply company in Warminster, Bucks County, he told his employers that his son, Joshua — a Navy crewman — died in a training accident in 2010 and was buried in Arlington National Cemetery.

His coworkers felt so sorry for Meleski’s loss that they organized a memorial service at the Willow Grove Naval Air Station, found a Navy chaplain to preside over the event, and raised money to host a luncheon in his dead son’s honor.

But Joshua did not exist.

Nor did the other son Meleski told coworkers about at his subsequent job. He said that one was an Army soldier who died in a helicopter crash in Iraq. The company cut him a $1,000 check to help pay for funeral expenses.

The lies that would eventually send Meleski back to prison began in 2010, when he applied — and was approved for — VA medical benefits with his claims of derring-do in Beirut and falsified military records that showed he had been honorably discharged.

“I did things with the SEAL team that a lot of people didn’t experience, i.e. taking other’s lives,” he told the VA doctors, according to records prosecutors put forward in court.

Because of the way VA benefits are allocated, Meleski’s fabricated past as a prisoner of war enabled him to receive expedited status for treatment — ostensibly over other former active-duty members of the military who deserved the benefit.

“The infuriating fact of this case is that … Meleski was offered health insurance from his employer at the mere cost of $10.97 per biweekly payment,” Assistant U.S. Attorney Megan Curran wrote in court papers in advance of Wednesday’s hearing. He “declined that … after submitting a form to his employer that he received VA medical care.”

Meleski’s lies began to unravel in 2018, when he applied for additional VA and Social Security disability pay, claiming prolonged PTSD. The VA discovered his phony record of service and contacted federal criminal investigators.

Yet, he continued to perpetuate the fiction. Just days before his arrest a year later, Meleski posted to Facebook: “If you haven’t risked coming home under the flag, don’t you dare disrespect it.”

The July 2020 court appearance when Meleski stood before Savage to plead guilty to counts including health-care fraud, falsifying military records, and falsely claiming military service may have been one of the few times in recent years that Meleski was telling the truth.

The sentence Savage imposed Wednesday included time for a separate case in which Meleski has admitted he induced his girlfriend to buy two pistols for him that he, as a convicted felon, was not legally allowed to own.

In addition to the prison term, the judge ordered him to pay more than $300,000 in restitution to the Department of Veterans Affairs.