More than 100 other people, including many police officers, were injured.
The incident took place in the state of Oaxaca, where two high-profile union leaders were arrested last week, accused of corruption.
Members of the CNTE union, which has a history of radical activism, have been blocking roads in southern Mexico ever since the union leaders were arrested.
The authorities said the police were trying to clear the roads when unknown gunmen began firing at both sides in order to create chaos and conflict.
Mexico's National Security Commission originally said in a statement that the police officers involved in the operation near the town of Nochixtlan were not carrying guns,
But federal police chief Enrique Galindo later said that an armed unit was deployed after shots were fired at the police and the protesters by "unidentified people" not linked to the demonstration.
The state-owned oil company, Pemex, warned on Friday that it might be forced to close a refinery in the area if the highway linking Oaxaca to the capital, Mexico City, remained blocked.
The dissident CNTE union opposes education reforms introduced by President Enrique Pena Nieto in 2013.
The changes include new measures to assess teachers' performance.
Union members say the corruption allegations against their leaders are politically motivated.
Ruben Nunez was accused of siphoning off money raised illegally from union members. Prosecutors also accused him of money laundering.
"He raised more than 24m pesos ($1.3m; Â£900,000) illegally between 2013 and 2015," said prosecutor Gilberto Higuera.
For two years the union demanded a 3.5% cut of purchases made by unionised members from some businesses in Oaxaca, according to Mr Higuera.
The money was taken from the education workers' payslips, which prosecutors say was controlled by the union.
Mr Nunez's deputy, Francisco Villalobos, was arrested for allegedly stealing textbooks.
Six people have been killed in southern Mexico in clashes between protesting teachers and police.