MEXICO CITY (Reuters) - Five Mexican police officers were shot dead on Tuesday in an ambush in the State of Mexico, where elections at the weekend will serve as an early referendum on the ruling party ahead of a 2018 presidential vote.

The police officers were responding to a call in Ecatepec, a sprawling suburb of Mexico City, early on Tuesday morning when unknown assailants opened fire on them, said an official in the state prosecutor’s office who was not authorized to speak publicly.

The Ecatepec mayor’s office said in a statement three police officers died at the scene, while two more died of their injuries. All five of the slain officers were men.

Ecatepec is among Mexico’s most dangerous urban areas, with various local gangs fighting over drug, prostitution and extortion rackets.

Sunday’s gubernatorial election in the State of Mexico could bring an end to almost nine decades of rule by President Enrique Pena Nieto’s Institutional Revolutionary Party (PRI) in Mexico’s most populous region, where 16 million people live.

Losing the state would put a big dent in the PRI’s hopes of retaining the presidency next year.

Opinion polls show the National Regeneration Movement (MORENA), the new party of veteran leftist Andres Manuel Lopez Obrador, could capture the state, which would ramp up the momentum for his bid to succeed Pena Nieto in 2018.

Pena Nieto is barred by law from seeking re-election.