Christopher Bartley initially told officials that he was trying to refill a butane lighter when it exploded. Bartley later admitted he'd lied.

GREENBELT, Md. — The former police officer for the National Institute of Standards and Technology, who caused an explosion as he tried to cook methamphetamine in a NIST science lab, was sentenced in federal court Thursday.

Christopher Bartley took the stand before he was sentenced by U.S. District Judge Peter Messitte.

Bartley was convicted and sentenced to 41 months in prison.

Early Thursday, a NIST firefighter, who responded to a silent heat alarm after the explosion in July 2015, said despite second-degree burns on his arm, Bartley’s first words were, “What the [expletive] are you all doing here?”

Bartley, who pleaded guilty in August, initially told first responders and his supervisor that he was trying to refill a butane lighter, when it exploded.

Hours later, NIST police lieutenant Gary Young received an email from Bartley admitting he’d lied.

“I really messed up tonight,” Bartley wrote. “I told the butane lighter story simply because I was so embarrassed that I made such a colossal mistake.”

Bartley and his lawyer have insisted he was attempting to make meth from available materials as part of training exercise, to show other officers how easily it could be done.

Prosecutors say Bartley put first responders and other NIST employees at risk by continuing to tell the butane lighter story, which resulted in first responders not taking appropriate precautions, including using respirators and gloves.

Robert Smith, an agent with the Drug Enforcement Administration, studied the pictures from the lab after the explosion. He said errors when mixing the ingredients most likely led to the blast, which created a fireball.

Smith testified that the substances that coated counters and floors could have put first responders at risk if they were to touch them.

After the blast, Bartley took what was left of the experiment to a nearby dumpster and Smith testified that the remnants could have exploded in a secondary blast, days or even weeks after the initial incident.

Bartley’s father, Thomas Bartley, took the stand Thursday and asked the judge for leniency. Bartley said not only did this “lack of judgment” cost his son his job, but now he is also a felon.

“He is already carrying out his sentence,” Thomas Bartley said.

Before the judge delivered his decision, Bartley, fighting back tears, told the court that he made a “serious error in judgment.”

Judge Messitte said he didn’t believe that Bartley was making the meth for future training. The judge referenced the popular television show “Breaking Bad,” saying that the main character — Walter White — went to the desert in a bus to make meth, but in Bartley’s case he went to a government facility, which put others in danger.

Messitte said Bartley committed the crime at a place he was sworn to protect and that sentencing him to prison time will put the word out to other officers who may think about perpetuating crimes in their position of trust.

Bartley was allowed to go home, but will need to report to jail on March 1. Once released from prison in 2019, he will have 2 years of supervised release.

After reading the sentence, the judge said Bartley will from here on be known as the “guard that broke bad.”