The entire police force of a Mexican town has been arrested on suspicion of involvement in the murder of a candidate for mayor.

Twenty-eight police officers from the town of Ocampo were detained by the police’s internal affairs department.

State authorities issued a statement saying the probe focused on potential violations of the police code of conduct, without giving more details.

However, local media said the officers were held on suspicion of being complicit in the killing of Fernando Angeles Juarez, who was running for mayor of Ocampo.

Mr Juarez, the mayoral candidate for the leftist Democratic Revolution Party, was shot dead on Thursday.

His party issued a statement saying he had been assassinated and called on the government to provide protection for those running in the 1 July elections.

After he was killed, Ocampo’s public security secretary, Oscar Gonzalez Garcia, was accused of involvement, the BBC reported.

View of the hearse carrying Fernando Angeles Juarez (Getty Images) (AFP/Getty Images)

Mexican federal agents were prevented from arresting him on Saturday by local police officers.

On Sunday, they returned with reinforcements and arrested the town’s entire police force.

Mexico will vote for a new president on 1 July, alongside hundreds of other federal, state and municipal posts.

Relatives of Fernando Angeles Juarez carry the coffin at his funeral (AFP/Getty Images)

This year’s election has been the bloodiest in Mexico’s modern history.

Dozens of politicians, candidates and activists have been murdered by criminal groups and gangsters seeking to influence the shape of the post-electoral map.

Almost all of the 18 candidates killed across the country so far have been running for local posts.