TAMPA — A Hillsborough judge on Friday sentenced former Tampa police Officer Brian Morales to six years in prison for having sex with an underage girl, one of the many students he was supposed to protect in his job as a school resource officer.

Calling Morales "a disgrace to law enforcement and an embarrassment to the Tampa Police Department," Hillsborough Circuit Judge Christopher Sabella said he agreed with prosecutors that Morales should be held to a higher standard because of his position as a police officer.

"He victimized a minor student who he was entrusted to protect. He violated the law he was sworn to uphold," Sabella said.

At the time of his arrest in 2013, Morales worked at Blake High School in Tampa, and it was there that he met a 17-year-old girl who was working the concession stand at a baseball game. She testified Friday that she sought him out because she was interested in becoming a police officer and that, initially, their relationship was that of a mentor to a student.

But over a period of months, their talks and text messages turned flirtacious, and school staffers began to notice how much time they were spending together. Someone at the school called the girl's mother, who confronted Morales in the parking lot, where he promised that he wasn't interested in her daughter.

Yet in secret, he and the student discussed having sex on her 18th birthday, which also happened to be the night of the high school prom.

"We talked about what would happen if we had sex" before she turned 18, the girl testified. "How it would ruin both of our lives."

That grim prediction proved both accurate and an insufficient deterrent. Prosecutors said Morales and the girl had sex as many as eight times while she was still 17. He was 36, married and a father. They told each other they were in love.

Their relationship might never have come to light if the girl had not been diagnosed with a sexually transmitted disease. At first, she tried to cover for Morales, but ultimately she revealed their affair to her mother, who called her softball coach, who called the principal, who called the police.

Although prosecutors argued for prison time, Morales' attorney, Rick Terrana, said his client deserved probation. He said Morales' wife is pregnant with twins and that imprisoning his client could put his life in danger, as other inmates were not likely to look kindly on a former police officer and newly registered sex offender.

"She was in love. He was in love. Had she not contracted this condition, we would not be here," Terrana said, adding that the girl "was a willing participant, perhaps even an initiator or an aggressor."

According to a forensic psychologist who testified on Morales' behalf, the former school resource officer was suffering in 2013 from psychological problems left untreated from his time in the Army. He was later diagnosed with post-traumatic stress disorder. Morales was also abusing anabolic steroids, which can increase impulsive behavior, the psychologist said.

Shortly before he was sentenced, Morales apologized to the girl and her family.

"Back in 2013, I was not in a good place," he said. The young woman had "filled a void and gave me the attention, friendship and compassion that I longed for. I began to fall in love with her, and saw a future together, and it was the cure-all for all my problems. Unfortunately, I made the worst decision and the biggest mistake of my life. Certainly there is no one else to blame but me."

Contact Anna M. Phillips at aphillips@tampabay.com or (813) 226-3354. Follow @annamphillips.