A 21-year-old man who allegedly brandished a handgun outside a Dublin garda station, before a young boy later fired it in the area, has been sent forward for trial.

Josh Larkin was charged with weapons offences for possessing a black handgun and producing it in the course of a dispute, at Gateway Crescent outside Ballymun Garda station in the city's north side on April 28.

Unemployed Larkin, of Poppintree Crescent, Ballymun, also faces a connected charge for possessing cannabis at Sillogue Park on the same date.

On April 30, bail was set at €20,000, with a €6,500 cash lodgement required, and he remains in custody.

He appeared at Cloverhill District Court on Thursday when the Director of Public Prosecutions issued directions for trial on indictment before a book of evidence was served on Larkin.

Judge Patricia Cronin granted a return for trial order sending him forward for trial to appear at Dublin Circuit Criminal Court on October 22 next.

An earlier bail hearing was told the incident was connected to a local gang feud.

Garda Ben Grimes said that at about 3.13 pm, he and a colleague were about to go out to conduct routine enquiries in the district when they observed what appeared to be three males in an altercation directly opposite the station.

Grimes said one of them brandished a handgun at people, but he fled on an e-scooter when approached.

Gardaí circulated the male's description and gave chase to Sillogue Park, where the accused was allegedly arrested.

Ballymun gardaí recovered "impeccable" quality CCTV from seven locations, the court heard.

Grimes alleged the accused was caught red-handed and that there was strong evidence. He said footage showed the accused as he "casually" brandished the firearm in front of people directly across from the station.

The garda said video evidence showed the accused placing the gun under a bush, and he threw away gloves and underpants that he had around his neck as a snood.

Referring to the footage, the officer alleged: "Moments after the handgun is dumped in a bush in Sillogue Gardens, it was picked up by a six-year-old child. The child hands it to his 11-year-old brother, who accidentally discharges it".

The boy was treated for a shoulder injury from the gun recoil, and the gun was unaccounted for, the court had heard.