Christopher Quilligan, aged 23, pleaded guilty at Dublin Circuit Criminal Court to violent disorder and possession of a revolver at Smithfield on Mar 6, 2011.
The fair was the biggest of the year and attracted up to 4,500 traders, tourists, and members of the public.
Violence erupted on the day between two groups involved in a dispute. A number of other people have already been sentenced for their roles in the incident.
Quilligan, formerly of Sundale Drive, Tallaght, but now living in Newbridge, has 13 previous convictions for minor offences. Judge Martin Nolan said Quilligan was a young man caught up in the throes of a feud at the time and had fired two shots indiscriminately close to a crowd in order to terrify his opponents. He said he was satisfied he was not a ringleader but it was a serious offence and he must undergo a substantial sentence.
He took into account factors such as his expression of remorse, his record of minor convictions and the time he has spent in custody. Judge Nolan imposed a five-year sentence and said that was as lenient as he could be in the circumstances.
Garda Colm Kelly told Michael Bowman, prosecuting, that witnesses, including a press photographer and cameraman, were able to give a description of a male letting off two shots in an indiscriminate manner.
Nobody was injured.
Gardaí also recovered photographs of the man with a stick in his hand.
Garda Kelly said CCTV and stills from the photographer and cameraman facilitated identification of the people involved. Quilligan was arrested the next May.
Garda Kelly agreed with Paul Greene, defending, the background to this offence involved two family groups who had been involved in a dispute which began in the West of Ireland.
Mr Greene said his client moved from Tallaght to Newbridge where he no longer associated with any faction involved in the dispute. He said Quilligan is a family man who has been in employment in the recent past. Mr Greene said Quilligan is remorseful and to the extent where he harmed himself before a previous court date.