A married police officer had sex with a 14-year-old girl at his home after texting her saying 'it would make me as bad as a paedophile' if their affair was discovered.
Christopher Semak is alleged to have exchanged hundreds of text messages with the schoolgirl, including one in which he said the relationship could see him jailed.
Prosecutor David Jackson told Stafford Crown Court the 33-year-old officer was arrested after the teenager confided in a teacher.
But Semak, from Kings Norton, Birmingham, denies having any sexual contact with the girl.
Among the texts sent by Semak is one alleged to have read: "If we did things and it got out I could lose my job. I could even go to prison because you are 14. It would make me as bad as the people I am trying to stop. It would make me as bad as a paedophile."
Jurors were told numerous 'sexually explicit' texts were found on the girl's phone by her parents, who confronted Semak but did not contact the police.
Mr Jackson told the court: "It was obvious to them [the girl's parents] that, in their minds, sexual activity was taking place between the two people exchanging the messages and that sexual activity had already taken place."
The court heard that the alleged told her parents she had been in a mutual relationship with Semak and did not want the police to be contacted.
But the girl then spoke to a teacher at her school, which led to the involvement of child protection officials and the police.
Semak was arrested in January 2012 and gave detectives a prepared statement claiming the girl had asked him for advice.
Semak said the teenager had threatened to falsely inform the police that they had had sex, prompting him to 'stupidly' respond to her texts.
In his statement to the police, Semak claimed: "I feared she would make a false allegation if I did not respond in this way."
Concluding his opening speech to the jury, Mr Jackson said Semak's case was that his victim had invented her account and then blackmailed him.
The officer, who has been suspended from duty since April last year, has pleaded not guilty to five counts of sexual activity with a child. The trial continues.
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more