Police in Puebla state say the men aged 53 and 21 had been detained in the township of Acatlan and taken to a local police station.
A crowd of about 150 people gathered and stormed the jail, taking the men who they accused of trying to steal children.
Some residents of a small town in central Mexico pulled two men accused of trying to kidnap children from police custody and burned them to death.
The crowd then doused them with an accelerant and burned them and their vehicle.
Moments later, family members of the two men arrived and demanded their own justice because the two men were innocent and peasants from the community of Tianguistengo.
The state police said Wednesday that local authorities had not followed established procedure to request reinforcements and negotiators.
Such instances of mob killings have been increasing in central Mexico. In January of 2016, another lynching occurred in Acatlán, in the neighborhood of San Cristóbal, when neighbors discovered a man identified as Víctor N., robbing a home.
Although the man was rescued, he died in the hospital as a result of the blows that the settlers gave him.