A Ministry of Defence worker from Trowbridge who got a 13-year-old girl pregnant has been spared a jail term.

Ryan Tiley, 20, was unaware of the girl's age when they first met through a mutual friend and at first thought she was 16.

But even after finding out the truth the IT worker continued so see her and eventually got her pregnant.

Tessa Hingston, prosecuting, told Swindon Crown Court yesterday that the pair got together in January 2013. The girl's Facebook page suggested she was 16 years old.

After a while Tiley realised the truth and cooled the relationship, but soon after it started up again and within a few months they were having sex.

In the autumn of last year the girl became pregnant and the matter was reported to the authorities by the midwifery service.

In a victim personal statement the girl said: "If I could rewind time I would never have had sex with Ryan."

Tiley, of Cock Hill, Trowbridge, pleaded guilty to sexual activity with a child.

Emily Evans, defending, said: "The relationship began in January 2013 the defendant having met the victim through a mutual friend.

"Late April or May last year he realised her true age after hearing a conversation between her parents. He said he was quite shocked."

She said he had been working at the MoD as an IT consultant and had been in the job for almost two years.

"What Mr Tiley says is he was a complete idiot, in his terms. He made a mistake. He has accepted responsibility all the way through," said Ms Evans.

Judge Tim Mousley QC imposed an 18-month community order with supervision, told Tilley to pay a £60 victim surcharge, and register as a sex offender for five years.

The judge said: "You were 18 when this all happened. She was 13. You are described as immature.

"You initially thought she was 16 but very soon after became aware she was not. This case came to light when she was four months pregnant.

"There was no grooming or other aggravating features. There is absolutely no suggestion any other young girl will be at risk from you and I take that into view."