An escaped prisoner who hid in a wheelie bin after driving the wrong way down a motorway at night while trying to avoiding pursuing gardaí has been given a five-year prison sentence, with the final 18 months suspended.

Liam Deegan, 27, was discovered in the bin after the Garda Air Support Unit, which was called in to assist in the chase, detected a heat source coming from it.

He had abandoned his car, a Volkswagen Passat, in the forecourt of a nearby garage.

He was unlawfully at large from Mountjoy Prison at the time.

Garda John Ryan told Garret Baker, prosecuting, that at 2am that morning he had instructed Deegan to pull over after he witnessed him driving too close to the vehicle in front of him.

The man pulled over into the hard shoulder but as soon as gardaí drove in behind him, he reversed, performed a u-turn across three lanes of traffic, and drove the wrong way down the M50.

A second patrol car happened to be in the area at the time and had to take evasive action when the driver realised that Deegan's vehicle was coming straight at him at speed.

He had initially thought the vehicle was on the opposite carriageway.

Gda Ryan said that on arrest Deegan said he had panicked when he was initially pulled over as he was disqualified from driving.

The garda did not discover that he was an escaped prisoner until later.

Deegan, of Rathmore Drive, Tyrellstown, Dublin, pleaded guilty at Dublin Circuit Criminal Court to endangerment between junctions 7 and 9 on the M50 on 22 April 2017.

He has 39 previous convictions including violent disorder, assault, threat to kill, false imprisonment and robbery.

Gda Ryan said he was on mobile patrol when he indicated that Deegan should pull over.

He was involved in the pursuit for some time before he lost sight of the Passat.

He agreed with Niall Storan BL, defending, that it was "nothing short of a miracle that no one was injured".

Mr Storan said his client is from a family of ten and is a qualified roofer. He has been told that there is a job available to him upon his ultimate release from prison.

Counsel accepted that his client has a history of serious offending but said he is willing to engage with the Probation Service.

"He is deserving of a chance," Mr Storan submitted adding that Deegan has a supportive partner and family.

Judge Melanie Greally said the garda who Deegan drove straight at was "fearful for his life" and added that given his driving any motorist who encountered him was "very unlikely to escape with their life or at the least serious injury".

She accepted evidence that he later offered a genuine apology to gardaí for his driving.

Judge Greally also noted that Deegan had indicated in a letter written to the court that he "desires and needs" to have assistance from the Probation Service upon his release from prison.

She suspended the final 18 months of the five year sentence on strict terms including that he engage with the Probation Service for 12 months upon his release from prison.