Image caption The elections were the last major test until the 2012 presidential poll

Mexico's main opposition party, the PRI, appears to have been the biggest winner in elections for state governors, mayors and local deputies.

But with most of the votes counted, the victories were not on the scale the PRI had expected.

President Felipe Calderon's party and its allies seemed set to take some governorships held by the PRI.

Violence overshadowed the campaign, with two candidates killed, but election day was relatively peaceful.

Sunday's elections were held in 14 of Mexico's 31 states, with 12 states choosing new governors.

The Institutional Revolutionary Party (PRI) had hoped to pick up momentum in its effort to regain the presidency in the 2012 election.

According to results so far, the PRI - which already held most of the governorships at stake - held on to six states and retook the states of Zacatecas, Tlaxcala and Aguascalientes.

MEXICAN ELECTIONS 4 JULY 14 of Mexico's 31 states held elections

12 chose new governor

Elections also for state deputies, mayors and councils Shadow over Mexico elections

"This election proves the PRI is the leading political force in the country," the party's president, Beatriz Paredes, told reporters.

However the National Action Party (PAN) and its allies were on course to win three states previously held by PRI.

These include the southern state of Oaxaca, which saw months of at times violent protests in 2006 against the then PRI governor, Ulises Ruiz.

The PAN and its allies were also on course to win for victory in the central state of Puebla, and in Sinaloa, which is one of the areas hardest hit by drug-related violence.

"These are historic victories," the PAN president Cesar Nava told the Associated Press.

"Sinaloa has a fundamental significance when it comes to Mexico's security. In Puebla and Oaxaca, the victory means a significant break with entrenched strongman politics."

The elections were seen as an unofficial referendum on President Calderon's crackdown on drug cartels.

Low turnout

Some 5,000 deaths so far this year have been blamed on drug-related violence and it has also touched the electoral process itself.

Image caption Egidio Torre secured victory in Tamaulipas

Rodolfo Torre, a front-runner candidate for governor in the north-eastern state of Tamaulipas, was killed after gunmen ambushed his convoy on 28 June. Four of his aides also died.

His brother, Egidio Torre, who replaced him as candidate, was elected governor.

A mayoral candidate in Tamaulipas was also killed, while other candidates stepped down and 550 electoral officials resigned.

Turnout in Tamaulipas was reported to be low. Only a third of voters cast their ballots in Chihuahua, the most violent state, according to the Associated Press.

The PRI held power for decades until the 2000 election which was won by the PAN candidate Vicente Fox.

He was succeeded in December 2006 by Mr Calderon, who declared a "war on drugs", deploying thousands of troops to violent areas.