A man caught by “paedophile hunters” was jailed for 40 months on Friday after his lewd online chat with a woman who he believed was a girl of twelve.

Caernarfon crown court heard the group had confronted unemployed Anthony Hughes, 51, at his flat in Menai Bridge, Anglesey, and broadcast it on Facebook. Police were also alerted.

Hughes pleaded guilty to attempting to incite a child to engage in sexual activity and attempted sexual communication with a child between September and December.

Prosecuting counsel Elen Owen said the paedophile hunters “decoy” told Hughes she was a schoolgirl. But there was “grooming” behaviour by Hughes and he sent a video of himself doing a sexual act and made lewd requests.

The barrister said Hughes told police he was “disgusted” with himself and sought to deny being sexually attracted to children.

Defence barrister Simon Rogers said the case involved internet contact and Hughes was of previous good character.

“This is a man who has behaved entirely out of character and will never offend in a similar way again,” Mr Rogers said. The defendant suffered from ill health and the humiliation of the confrontation by paedophile hunters and streaming of it on social media had a significant effect.

Judge Huw Rees said Hughes had to move from Menai Bridge to bed and breakfast accommodation in Caernarfon until matters settled.

He said it was repeated offending and Hughes must register as a sex offender and a sexual harm prevention order was made.