HARTFORD, Conn. — A former airman who received an honorable discharge from the Air Force despite acknowledging he had a sexual relationship with a 14-year-old was sentenced Wednesday to five years in federal prison on child sex charges.

Nicholas Murphy, of Exeter, Rhode Island, pleaded guilty in June to federal charges of traveling from his home in Rhode Island to Plainfield, Connecticut, in 2015 while on leave to have sex with the girl.

Murphy, who was 25 at the time, avoided a dishonorable discharge by convincing the Air Force that he believed the teen was at least 16 years old. The military considers “a mistake of fact as to age” to be an affirmative defense, according to a sentencing memorandum.

“There was never anything that would lead me to believe she was younger than 16,” Murphy wrote in a memo to the discharge board. “She certainly didn’t look under 16, either in person or in her pictures on Facebook. She was also very open and forward in talking about sexual things, and spoke like someone who was much older.”

But federal prosecutors cast doubt on Murphy’s assertion, noting the teen’s Facebook page included her actual date of birth.

“In the comments on a photo posted in the beginning of their relationship, the minor victim wrote that she was thirteen years old. In a status update during their relationship, the minor victim wrote ‘I’m in 9th grade!!! YAY!!! I wish i could go to highschool with u guys though, im sorry,’” prosecutors wrote.

An Air Force spokesman declined to comment, saying he would have to research the case.

Prosecutors said the two met on an internet dating site, and first had sex in May or June, 2015, when the teen was still a virgin. The two remained in contact while Murphy was stationed overseas, exchanging photos.

Police initially became involved in the case when the victim’s parents reported her missing from their home on Sept. 16, 2015. Prosecutors said she and Murphy, who was home on leave, had arranged for the girl to sneak out of her house and meet at a local park, where they had sex in his pickup truck.

In addition to the prison sentence, Murphy must serve five years of supervised release.