BEIJING — In a rare case of gun violence in China, a man fatally shot five people and beat a sixth to death, including some of his factory colleagues and a soldier, police said Sunday.

The 62-year-old man's killing spree started when he used unspecified tools to beat a colleague to death over an economic dispute, according to Shanghai police. The man identified as having the surname Fan killed his colleague on Saturday afternoon at a chemical factory in Shanghai's Baoshan district, the Shanghai Public Security Bureau said on its microblog.

The bureau said Fan then took a hunting rifle that was hidden in his dormitory, asked a driver to take him to another district and then shot him on the way. After killing the man, Fan drove the vehicle back to Baoshan and killed a soldier who was guarding the entrance to a barracks. He also took the soldier's gun.

Fan then returned to the factory and fatally shot three more people with his hunting rifle, including a manager. Police said they captured him in the factory about six hours after his killing spree started.

Guns are hard to come by in China. Firearms are tightly controlled and private ownership is for the most part illegal. Citizens who have hunting permits may apply at their local police station for permission to own a hunting rifle.