A 71-year-old man indecently exposed himself in Blackburn Market after becoming aroused by looking at a 12-year-old girl in school uniform.
Blackburn magistrates heard Steven Duxbury told police he had simply lost control.
Duxbury, of Mill Lane, Blackburn, pleaded guilty to indecent exposure and engaging in sexual activity in the presence of a child.
He was sent in custody to Preston Crown Court to be sentenced after the magistrates ruled their powers of punishment were inadequate.
Scott Parker, prosecuting, said Duxbury had convictions for possessing indecent images of children in 2012, when he was made subject to a sexual harm prevention order, and from 2017, when he was jailed for 12 months.
“There was a suggestion in that case that he had engaged in (a sex act) on a bus in front of a schoolgirl,” said Mr Parker.
In the latest case the police attended a report of a man on Blackburn Market who had been performing a sex act and his behaviour had been witnessed by a child.
He said the 12-year-old girl saw the defendant sitting on a bench and he kept looking at her making her feel uncomfortable.
“She looked again and could see he was (performing a sex act) and licking his lips,” said Mr Parker.
“She told her mother who could clearly see what he was doing. He was detained by security until the police arrived.”