The man, identified as Ljubisa Bogdanovic, used a handgun in the shooting spree at five houses in Velika Ivanca, a village 50 kilometers (30 miles) southeast of Belgrade, emergency hospital spokeswoman Nada Macura said.
Twelve people were killed immediately between 5 a.m. and 5:30 a.m. and one person died in a Belgrade hospital, Serbian police chief Milorad Veljovic said. The man and his wife were both severely injured by the shootings and another person was also injured, Macura said.
"Most of the victims were shot while they were asleep," Veljovic told reporters. "The most harrowing scene discovered by police was the dead bodies of a young mother and her two-year-old son."
He said the motive for the killings was unclear.
Although such shootings are relatively rare in Serbia, weapons are readily available, mostly from the 1990s wars in the Balkans. Media reports said the suspect had a license for the handgun.
Residents said the man first killed his son and his mother before leaving his house and then began shooting his neighbors. They expressed shock, describing the suspect as a nice quiet man living in one of a dozen modest homes that make up this village set on a lush green hill covered with fruit trees.
"He knocked on the doors and as they were opened he just fired a shot," said resident Radovan Radosavljevic. "He was a good neighbor and anyone would open their doors to him. I don't know what happened."
Neighbors said an entire five-member family was shot dead in one house, including the small boy who was the suspected killer's cousin.
Milovan Kostadinovic, another neighbor, said the suspect was confronted by police while en route to Kostadinovic's house.
"If they didn't stop him, he would have wiped us all out," Kostadinovic said, standing in front of his two-story, red tile- roofed house. "He shot himself when police stopped him."
The suspect had lost his job last year and fought as a Serb soldier in the war in Croatia in 1992, the police chief said. Villagers said Bogdanovic fought in Vukovar, the eastern Croatian town that was destroyed in a massive Serbian-led army offensive - the scene of the worst bloodshed during Croatia's 1991-95 war for independence.
Macura, the hospital spokeswoman, said the shooter had no known history of mental illness. Stanica Kostadinovic, another neighbor, said the man's father had hanged himself when he was a young boy and his uncle had a history of mental illness.
Doctors said later Tuesday that the suspect's condition was critical but his wife was able to communicate with hospital staff.
Serbian Prime Minister Ivica Dacic said the killings showed that the government must pay more attention to gun control laws and other social problems facing the Balkan nation, which is still reeling from the 1990s wars.
The Serbian government held an emergency session Tuesday and was expected to proclaim a day of national mourning.
Police blocked off the village while forensic teams and investigators in white protective robes took evidence from homes where the shootings took place.
Serbia's last big shooting spree occurred in 2007, when a 39-year-old man gunned down nine people and injured two others in the eastern village of Jabukovac.
Sabina Niksic contributed from Bosnia.