The President of Mexico has suffered a hefty defeat at the polls after taking moves to recognise same-sex marriage.

Mexico has seen a string of court battles over same-sex marriage, with Mexico’s Supreme Court last year ruling that it was unconstitutional for states to ban LGBT couples from marrying – leading to Mexican states recognising same-sex marriages.

Last month, the country’s leader Enrique Peña Nieto announced he would pursue country-wide reforms to codify into law the right to recognise “the right to enter into marriage without any discrimination”.

Announcing the move on Twitter on International Day Against Homophobia, Transphobia and Biphobia, he said: “I signed reform initiatives to boost the #MatrimonioIgualitario is enshrined in the Constitution and the Federal Civil Code”.

However, the move has sparked a backlash from the country’s strong Catholic ‘traditional values’ lobby, and Nieto’s party is being punished in the local elections this week.

The President’s PRI Party appears to have lost seven governorship elections with gains for social conservatives – a warning sign ahead of the Presidential elections in 2018.

Though the President is unpopular for a number of reasons, more than a thousand religious and social conservative groups had founded a coalition known as the National Front for the Family which appears to have contributed to the punishing result.

The president of the Mexican Council for the Family, Juan Dabdoub Giacomán, told the Catholic News Agency that the outcome showed a clear “protest vote… to oppose the decision of President Peña Nieto to regularize so-called homosexual ‘marriages’ and adoption.”

He added: “The important part was that in less than three weeks an organization was created that was able to mobilize an entire country against an initiative of the president attacking the family, calling for a protest vote against him and his party.”

Giacomán warned that if Nieto continues his reforms, the coalition would work against him in the Presidential election too.

He said: “We don’t want [the re-election] of a party like the Institutional Revolutionary Party, which has openly declared itself, through the voice of its president, as an anti-family party.

National Front for the Family spokesperson Carlos Alberto Ramírez Ambríz told CNA: “Mexico has spoken at the ballot box; the affront against the family has cost the president and the party that supports him dearly.”

“Mexican society is tired of the corruption, impunity and arrogance that the PRI represents in Mexico and that fatigue was seen reflected in the recent elections.

“This weekend the family won! It was an historic event for Mexico; everything indicates that society is waking up and we’re not going to go on allowing a corrupt political system to continue governing.”