Officers on the ground during one of the worst outbreaks of street violence linked to 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 charges of 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 5 January.
Police came under sustained attack from crowds throwing masonry, fireworks and other missiles.
The court was told it was one of the most serious episodes of trouble since the decision was taken to limit the flying of the union flag at Belfast City Hall.
A man dressed in black and wearing a balaclava was emerged holding what was thought to be a handgun.
"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 police 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.
According to the prosecution he was wearing the same distinctive trainers.
But defence counsel Mark Farrell stressed the charges were disputed and argued that there is a break in the continuity of the footage.
Mr Farrell also pointed out that no modified weapon capable of firing proper rounds was involved.
He 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.
"In doing this he placed himself at risk because one police response might have been to return fire," the judge said.
"Fortunately for all of us it didn't happen."
Mr Justice Weatherup added: "Protest is permitted when lawful, but it's only too obvious that produce a firearm and pretend to be shooting 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.