MEXICO CITY — The federal police moved into this city’s historic central square on Friday to retake the space from thousands of teachers who had been occupying it for the past month to protest an overhaul of nation’s education policies.

The action took place in a matter of minutes as the teachers met a 4 p.m. deadline the government had imposed to leave the Zócalo, as the square is known. After a month of tolerating the encampment and almost daily marches intended to snarl traffic, both the city and federal government moved to end the occupation on Friday, two days before Mexico’s Independence Day celebration.

President Enrique Peña Nieto is to give the traditional shout of independence on Sunday evening from the balcony of the National Palace to a crowd that assembles in the Zócalo.

The teachers had been trying to block a measure requiring them to be evaluated or lose their teaching jobs. The measure reassigns them to administrative posts if they fail.