Thousands of riot police retook Mexico City's central Zócalo plaza and the surrounding area from striking teachers on Friday.

There were violent clashes but not the full-scale confrontation that had appeared likely at first.

Police moved into the area minutes after the elapse of a 4pm deadline the government had set for the teachers to leave the square they had occupied for weeks in protest against an education reform.

With helicopters circling low overhead, some police contingents fired teargas as they advanced.

Officers had to duck to avoid being hit by missiles thrown by protesters who had earlier prepared for the operation – by building barricades and amassing makeshift weapons including metal rods, planks and broken paving stones.

But other lines of police faced little resistance as they entered the huge expanse of the square itself from a different side.

They employed water cannon to put out bonfires made from rubbish and the remnants of the huge tent city where thousands of teachers had been based during the protests.

Most had already left by the time the police arrived. Two hours after officers moved in, the police appeared to have near total control of the area.

The government was determined to remove the teachers ahead of Mexican independence day celebrations on Sunday and Monday.

These traditionally include the president ringing a bell and shouting "Viva Mexico" from a balcony in the national palace that overlooks the square, alongside the cathedral, the country's most important Aztec ruins and the seat of the city government.

The teachers' protests have been conflict-ridden from the start, involving regular marches and blockades that have caused near continuous traffic chaos in the capital and which twice blocked access to the international airport for hours.

Initially the protests were aimed at pressuring the legislature into modifying a wide-ranging education reform that threatens teachers with dismissal if they fail evaluations aimed at improving the dismal standard of the country's state schools.

With the reform approved earlier this month, they began demanding that it be scrapped. They also demanded face-to-face negotiations with the nation's president, Enrique Peña Nieto.

Most of the striking teachers come from Mexico's poverty-ridden southern states, and argue that the country's educational deficiencies are more closely tied to social inequity than their performance in the classroom.

They belong to the smaller of the country's two teachers' unions – the National Education Workers Co-ordinating Committee.

The larger union, much weakened after the arrest of its legendarily powerful leader Elba Esther Gordillo in February, has supported the reforms.

Having lost control of the Zócalo, the protesters began regrouping at the nearby Monument to the Revolution.

Organisers said teachers were not responsible for the earlier violence, blaming radical supporters of the movement who had joined the protest just before the police moved in.