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.