Elba Esther Gordillo, the head of Mexico’s teachers’ union, was arrested in 2013 as she stepped from a private jet that had just flown in from California.

Known simply as “la Maestra” (the Teacher), Gordillo was notorious for her extensive plastic surgery, her eye-popping wealth and her mastery of bare-knuckle politics.

She was accused of embezzling nearly $2m from her union to finance luxury homes in San Diego and shopping sprees in the Neiman Marcus department store, and she was quickly imprisoned.

At the time, Gordillo’s vertiginous fall from grace was held up as proof that the incoming president, Enrique Peña Nieto, was serious about pursuing corruption. It also conveniently cleared the way for education reforms that had been fiercely opposed by her union.

Five years later, Gordillo has emerged on the public stage again – and this time she appears poised to assist none other than Peña Nieto, whose Institutional Revolutionary party (PRI) trails in the polls for the July 2018 presidential elections.

Gordillo, who has denied any wrongdoing, was released from prison last week and transferred to her penthouse in the capital’s posh Polanco district.

That same day the PRI forged an electoral alliance with the New Alliance (Panal), a small party previously controlled by Gordillo and the National Education Workers Union (SNTE).

The PRI presidential candidate, José Antonio Meade, said Gordillo’s release had “nothing to do with politics”, while the government said it was committed to pushing through the education reforms that would subject teachers to evaluations and crack down on corruption in the school system.

But the timing of the release has raised suspicions in a country where politics and justice often push in opposite directions.

Gordillo, 72, had been eligible for house arrest for two years, but until recently the attorney general’s office had fought to keep her in prison, even though she has not been convicted of any crimes.

For many, the case encapsulates the Peña Nieto administration, which began with heady talk of structural reforms and renewal but has been mired by corruption allegations, economic despondency and spiralling crime.

Peña Nieto is ineligible for re-election, and the landmark education reform has yet to be fully implemented. In contrast, the entrenched interests that the PRI had promised to sideline remain surprisingly resilient – and politically useful.

“This is how the administration started: the arrest was trumpeted as a great blow against corruption,” tweeted Max Kaiser, director of anti-corruption research at the Mexican Institute for Competitiveness, a thinktank.

“This is how the administration ends. It was all a show, nothing but fanfare. There was no heavy hand. To the contrary, impunity was the hallmark of the administration.”

Gordillo’s release has again highlighted the political heft of Mexico’s teachers, who often assume the role of authority figures in remote regions and exert a strong influence at election time.

“When the polling stations are in public schools, it’s teachers who run them – and there is a premium: a few points in favour of [the party they are supporting],” said Federico Estévez, a political science professor at the Autonomous Technological Institute of Mexico.

Traditionally, Mexican teachers have supported the PRI, which ruled uninterrupted until 2000 and returned to power in 2012. After the country transitioned from one-party rule in 2000, the union hedged its bets, forming alliances with other parties and creating Panal to protect its interests.

It remains unclear how much influence Gordillo retains over the teachers; Panal’s leadership says they have moved on without her.

Some observers say Gordillo’s imprisonment was as much about realigning the SNTE with the PRI, which expelled her in the mid-2000s for striking deals with the then president, Vicente Fox, of the National Action party.

“It was political promiscuity. The union got into bed with whatever party got into power,” said Ilán Semo, a historian at the Iberoamerican University. “They threw her in prison to make it clear that what she had done was no longer to be tolerated.”