2016-07-02T091929Z_1118768986_S1AETNFTTPAA_RTRMADP_3_SERBIA-SHOOTING
A police tape is seen in a cordoned area at a cafe after a shooting during a local festival in the village of Zitiste, north of Belgrade, Serbia, in this still image from video taken July 2, 2016. Courtesy of N1 via REUTERS TV

Five people were killed and another 22 were wounded early on Saturday when a man entered a cafe in northern Serbia and opened fire with an assault rifle, police said.

Police arrested the suspect, a man in his late 30s identified only as Z.S., immediately after the shooting during a local festival in the village of Zitiste, around 80 kilometers north of Belgrade.

Nebojsa Stefanovic, the interior minister, told Belgrade's B92 TV that Z.S. killed his estranged wife and a another woman, before firing at others in the cafe with an assault rifle he illegally owned.

"Jealousy could be a motive," he said. "He was a quiet man; he had no criminal record."

Gordana Kozlovacki, the director of the hospital in the nearby town of Zrenjanin, said 22 people were treated after the shooting. Seven remained in a serious condition.

Serbia and most of the western Balkans are awash with hundreds of thousands of illegal weapons following wars and unrest in the 1990s.

In a bid to reduce the number, Serbian police on Friday offered an amnesty over surrendering or registering illegal weapons until November.

Saturday's killings follow a number of mass shootings in Serbia in recent years.

Three years ago, 13 people died in a shooting spree in a village near Belgrade, and last year six people were killed in a dispute over a wedding in Serbia's north.