After returning to his hometown of Yema village in Huize county on Wednesday, Yang Qingpei killed his parents 'in a rage' after they refused to pay his debts.
Fearing he would be discovered by community members, Yang allegedly killed 17 neighbours, including three children, before escaping to the provincial capital of Kunming, where he works, state-run Xinhua news agency reported.
After an investigation, police identified Yang as the suspect and caught him the next day in Kunming, it said.
The suspect confessed to killing 19 people after a conflict with his parents, who were among the victims, police said.
More From This Section
The victims were members of six families. Further investigation led by the Ministry of Public Security is under way.
The bodies were found on Thursday at different locations in the village, a state-run news website said.
Mass killings are rare in China and the incident dominated discussion on social media platforms.