The violence erupted as anti-riot police moved in to dislodge protesters blocking a highway in the southern state of Oaxaca. Television footage showed chaotic scenes of men running from police as gunfire rang out.
It was the worst incident in a spate of protests over the past several months against education reforms that the government pushed through three years ago.
Enrique Galindo, the head of Mexico's federal police, said masked individuals who were not affiliated to the union were behind much of the violence, lobbing Molotov cocktails and shooting at police and civilians.
"These kinds of radicalised protests generate violence," he told a news conference in the state capital of Oaxaca City.
State Governor Gabino Cue gave the casualty figures, and said most of those who died were young people and only two had "links to the union."
Earlier in the day, police escorted 120 tanker trucks carrying chemical waste from the nearby Salina Cruz refinery, owned and operated by state-run oil company Pemex.
On Friday, Pemex warned it could be forced to shut operations at the refinery in "a few days" if the highway blockade persisted.
The unrest escalated after police arrested the leader of the local teachers' union during the previous weekend. Ruben Nunez, head of one of the most combative factions of Mexico's CNTE union, was detained on suspicion of corruption.
Nunez is secretary general of the CNTE's Section 22 in Oaxaca, a hotbed of resistance to government efforts to reform the education system.
Similar, if less violent protests, have frequently caused chaos in Mexico City. CNTE has led efforts to resist the education reform, in particular its mandate to carry out evaluations of teachers