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.
The incident happened at about 1:40 am (local time) in the town of Zitiste, around 80 kilometres north of Belgrade.
Police arrested the man, born in 1978 and named only by his initials Z.S., and opened a probe into the shooting.
Interior Minister Nebojsa Stefanovic visited the scene and was quoted by N1 television channel as saying that the weapon was illegal and jealousy was believed to be the motive.