A man accused of sexually assaulting a woman in a park had followed two teenage girls around the same location weeks earlier and performed a sex act on himself, it is alleged.
The 19-year-old woman went behind bushes to go to the toilet when Ahmed Yagoub (56) allegedly exposed himself to her and grabbed her between her legs.
In the earlier incident, he allegedly masturbated in front of two 16-year-olds after following them from a local shop.
Gardaí objected to bail, saying they believed Mr Yagoub had a number of different identities and the incidents he is alleged to have been involved in "appear to be escalating".
Judge Anthony Halpin deferred a decision on bail and adjourned the case for a week at Dublin District Court.
Mr Yagoub, of The Crescent, Millbrook Lawns, Tallaght, is charged with sexual assault and offensive conduct of a sexual nature by exposing himself and masturbating.
The prosecuting garda said the accused made no reply to one charge. To a second, he replied: "I didn't do it" and to the third he said: "I didn't do anything."
Objecting to bail, she said the most recent incident was alleged to have happened at a park in west Dublin on July 11. Two friends, aged 19 and 17, were socialising there and went to go to the toilet in bushes.
The 19-year-old pulled down her underwear and proceeded to go to the toilet when she noticed a man behind her. She pulled up her trousers and he grabbed her by the buttocks, then pinched over her clothes, the garda alleged.
The young woman jumped up and saw the accused had his genitals exposed.
The 17-year-old also saw the man's genitals and started screaming.
The girls ran out of the bushes and the suspect ran from the scene, the garda said.
They alerted a friend and he recorded the suspect on his mobile phone. A garda later identified the accused from the footage.
The garda said in an earlier incident, on June 26, two 16-year-olds were in a shop near the park when they saw the accused and believed him to be following them.
He said "hello" and they asked "are you following us?", the garda continued. He walked away and the girls left the shop and walked across the car park.
A witness said she saw the girls go into the park, with the accused following behind them. She could see him from behind and believed him to be masturbating, the garda said.
The two girls then turned around and it was alleged they also saw him masturbating.
The court was told the accused told gardaí in that alleged incident, he did see the girls in the shop and that he was in the park but offered the possible scenario that if he did take out his genitals, he may have been urinating. He denied any sexual offence.
The garda said the accused had arrived here from Argentina in January.