The court heard that Chan Chun-hin, 19, attacked a passer-by during a protest in Sheung Shui in December in 2019.
It also heard that he attempted to snatch a shotgun from a police officer while resisting arrest.
Chan was convicted after trial of rioting and attempted possession of firearms without licence, and he had earlier pleaded guilty to two counts of resisting a policeman.
In sentencing, Judge Frankie Yiu said the defendant had casually hurt an innocent person and disregarded law and order.
Yiu said it was fortunate that the trigger of the shotgun had been locked, or the consequences would be too dreadful to contemplate.
Chief Inspector Sung Ching-wai said the sentence could act as a deterrent:
“The defendant and 50 other protesters assaulted a male passer-by and snatched his phone for inspection. Police responded to the scene but the defendant assaulted an officer and resisted arrest,” she said.
“During the wrestle, the defendant grabbed the police’s Remington shotgun. He was subsequently subdued and arrested.”