A blank pistol fired at police during trouble in east Belfast was feared to be a bid to kill them, the High Court heard.
Officers on the ground during one of the worst outbreaks of street violence linked to Union flag protests believed at the time it was an act of terrorism, prosecutors said.
Details of the incident emerged as bail was granted to a gardener accused of having the fake weapon.
Thomas Finlay (38), of Cuba Walk, Belfast, denies possessing an imitation weapon with intent to cause fear, rioting, and failing to remove a balaclava disguise.
All of the alleged offences occurred during disorder in the Newtownards Road area on January 5 when police came under sustained attack from crowds throwing masonry, fireworks and other missiles.
A man dressed in black and wearing a balaclava had emerged holding what was thought to be a handgun, the court heard.
"The male then discharged what police believed were a number of rounds," a prosecution barrister said.
"That was directed at police lines and at the time this was occurring police believed that this was an attempt to kill officers and that it was an act of terrorism."
Investigations later revealed that a blank-firing pistol had been discharged.
Finlay is allegedly linked through CCTV images of the man at the time.
But defence counsel Mark Farrell stressed the charges were disputed and argued that there is a break in the continuity of the footage. He also pointed out that no modified weapon capable of firing proper rounds was involved.
Mr Farrell added: "There's no suggestion this man (Finlay) was either an orchestrator, organiser or provoker of this riot."
Ruling on the bail application, Mr Justice Weatherup acknowledged the police officers' belief that they were being fired on by whoever had the pistol.
He said: "Protest is permitted when lawful, but it's only too obvious that to produce a firearm and pretend to shoot at someone is no form of lawful protest."
Bail was granted on condition that Finlay does not go within 500 metres of any demonstration or parade. He was also curfewed and prohibited from concealing his identity in public by covering his face.