The man "entered the cafe and opened fire with an automatic rifle, killing his wife and another woman, then he continued to shoot at other citizens in the cafe," a police statement said.
It was the third mass shooting in recent years in Serbia, which has tried to shrink the large number of illegal weapons in circulation since the 1990s Balkan wars.
"It was horrible. Some people were screaming and there was blood everywhere," cafe owner Ljubomir Milinovic told state-run news agency Tanjug.
N1 television station quoted Interior Minister Nebojsa Stefanovic as saying that the weapon was illegal and jealousy was believed to be the motive.
The latest incident happened at about 1:40 am (2340 GMT Friday) in the town of Zitiste, around 80 kilometres (50 miles) north of Belgrade.
Police arrested the alleged shooter, born in 1978 and identified only by his initials ZS, and opened a probe into the killings.
Stefanovic said the attacker tried to flee the scene but was foiled by police.
"We are all shocked that something like this could happen, since this was a very quiet man who had no police record," the minister said, according to Tanjug.
N1 channel reported that the attacker argued with his wife in the cafe, left the building and returned with a Kalashnikov-type rifle.
Two people were killed instantly in the shooting and three others died in hospital in the nearby city of Zrenjanin, according to N1.
The other injured victims, some of them severely, were taken to various Serbian hospitals but were not in critical condition, reports said.
Unlawful weapons
Police have previously said there could be up to a million unregistered weapons in Serbia, including guns and grenades, left over from the 1990s conflicts.
This latest shooting spree came a day after the interior ministry launched a new amnesty to encourage owners of illegal weapons to hand them in to their local police stations.
A similar drive last year netted about 4,000 weapons.
A stricter gun control law came into effect in March in Serbia, which is home to about seven million people.
In another shooting spree last year, a 55-year-old man opened fire in a northern town in an apparent drunken rage over his son's wedding, killing six people including the bride and her parents.
In 2013, a 60-year-old Serbian war veteran shot dead 13 people in the country's worst massacre in two decades as he rampaged through his tiny village about 50 kilometres south of Belgrade.
The dead included his son and his mother as he went house-to-house, mainly shooting people as they slept peacefully.
Individual shooting incidents are reported almost daily in Serbia, with domestic violence a common theme.
After Saturday's attack, the government body for gender equality called for tougher gun control to prevent another incident where "in a burst of anger, someone decides to use an automatic rifle to kill his wife and her friends".
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ