A sailor who thought he was sending graphic messages and penis pics to a teen girl before going to meet her for sex was instead busted in a law enforcement sting and convicted at court-martial, according to Navy records and officials.

Hospitalman Mason L. Spence was stationed at Naval Hospital Bremerton, Washington, in 2017, when he first started communicating with someone he thought was a minor girl, according to military charge sheets released to Navy Times.

Between October 2017 and November 2017, Spence sent graphic messages to someone “he believed to be a 15 year old girl," plus photos of his genitals using the social messenger Whisper and KIK cellphone applications, the records show.

The court documents tell the rest of the story.

Spence traveled to a hotel in Silverdale, near the hospital, to meet and have sex with the girl. For his date, he “carried a pack of Gummy Bears and one can of Red Bull in his hands as agreed upon in social media correspondence, and entered the hotel room where he understood the 15 year old to be located for the purpose of committing sexual acts with her."

Law enforcement arrested Spence on Nov. 15 and he pleaded guilty to attempted sexual abuse of a child charges during a court-martial in Bremerton on May 14, according to the Navy’s Judge Advocate General Corps and hospital officials.

He was sentenced to a bad conduct discharge, reduction in rank to E-1 and 4 years behind bars.

As part of a pre-trial deal, however, he likely will serve 30 months in the brig.

Navy JAG officials said this week that May’s court-martial results were not posted until recently due to employee turnover.

Spence was transferred to the Naval Consolidated Brig at Charleston, South Carolina, in June, according to Navy personnel records.

Brig officials said this week that inmates are not allowed access to the media.

Naval Criminal Investigative Service officials would not comment on the sting or how Spence became known to law enforcement.

“NCIS combats child exploitation to reduce crime and the impact of criminal activity on the operational readiness of Department of the Navy forces,” NCIS spokesman Ed Buice said in an email. “NCIS uses all available law enforcement tools to bring offenders to justice.”

A Navy photo of Spence was included in an April 2017 command article showing him taking part in a “Chalk the Walk” event to bring attention to Sexual Assault Awareness and Prevention month.

In the photo, Spence scrawls the message that nearly one in five women and one in 71 men will be raped.

Stutz said Spence was simply taking part in the hospital’s event and was not one of the victims advocates in the Navy’s Sexual Assault Prevention and Response program.

“Spence was not part of our command Sexual Assault Prevention and Response program,” hospital spokesman Doug Stutz said in an email. “As part of Patient Administration Department, he supported registration, admissions, fleet consults, medical records maintenance, requests, and administrative support.”

The hospital command placed Spence in pre-trial confinement after receiving word he had been arrested on Nov. 15, Stutz said.

Navy leaders were particularly concerned about Spence’s “possibility of misconduct due to access to patient information, including telephone contact information for families and minors,” Stutz said.

“By keeping him in confinement, it prevented him from any access to patient records, along with being anywhere near any of the various command clinics providing services to family members, as well as keeping him off surrounding local military bases which also have military dependents,” Stutz said.

Spence enlisted in 2012, according to Navy records.