A man was arrested after gardaí caught him allegedly trying to throw a drugs package into a jail in the west of the city.
Keith Deegan (33) is alleged to have tried to hurl cannabis over the wall of Wheatfield Prison in Clondalkin, Dublin 22 from the grounds of a neighbouring football club.
He was granted bail despite Garda objections when he appeared in Dublin District Court.
Mr Deegan, with an address at Buttercup Park, Darndale, is charged with possession of cannabis with intent to supply.
The court heard the accused made no reply to the charge after caution. He was handed copies of the charge sheets.
Objecting to bail, the prosecuting garda cited the nature and seriousness of the allegations.
She said gardaí were on patrol last August 30 when they saw the accused acting suspiciously in the grounds of Cherry Orchard Football Club at around 6.20pm.
On seeing gardaí, it was alleged the accused dropped the package and tried to evade them.
He was caught after a short foot chase and arrested. Mr Deegan was brought to Ronanstown Garda Station.
It was alleged the accused was "caught red-handed".
Gardaí believed the accused would not attend court if granted bail.
Applying for bail, the defence said Mr Deegan could live at his mother's address at Moatview Gardens.
The objection to bail was "simply not made out" and there was "very little chance that this gentleman is going to abscond", she said.
Judge John Campbell granted bail in the accused's own bond of €100.
Under bail terms, Mr Deegan must stay away from Clondalkin, including Wheatfield and Cloverhill prisons, and sign on every Monday, Wednesday and Friday at his local Garda station.
The judge granted free legal aid after the defence made an application and said the accused was not working.
Mr Deegan was remanded on bail to appear in court again next February, for the directions of the DPP. He has not yet indicated how he intends to plead.