Mexican President Felipe Calderon's sister trailed on Sunday night in a very close state governor's election that is viewed as a key test of the government's popularity before next year's presidential vote.

Preliminary results in the president's home state of Michoacan in western Mexico showed the race to be too close to call, with Fausto Vallejo, the candidate of the opposition Institutional Revolutionary Party (PRI), just ahead of Luisa Maria Calderon of the president's National Action Party (PAN).

With votes counted in 62 percent of polling stations, the president's elder sister was at 33.1 percent, trailing Vallejo by 1.8 percentage points, the state's electoral institute said.

The vote in Michoacan, the final state election before the 2012 presidential ballot, was dominated by security concerns.

Some 45,000 people have died in drug-related violence in Mexico since Felipe Calderon ordered an army-led crackdown on drug cartels. He began the drug war in Michoacan in 2006.

A win for the PAN, which has never ruled Michoacan, could help the president rebuff criticism about his strategy from the PRI, the favourites to win the presidency in 2012. Mexican law prevents Calderon from seeking a second term as president.

A Michoacan victory would give the PRI a fourth consecutive state election success against the struggling PAN, helping to increase its increasing grip on Mexican politics.

It would also cement the party's status as front runners to triumph in the 2012 vote, said Fernando Dworak, a political analyst based in Mexico City.

With Michoacan, the centrist PRI, which ruled Mexico for 71 years until being ousted by the PAN in 2000, would control 20 of Mexico's 32 federal entities.

Luisa Maria Calderon had gained ground in opinion polls in recent weeks and was confident she could win the state.

The early count indicated the leftist Party of Democratic Revolution (PRD) will lose the governorship it has held for the past decade, with its candidate at 29 percent.

The Michoacan race was so tight that candidates from all three parties declared themselves victors after polling stations closed, citing their own exit polls.

By claiming the win, the parties could be seeking to create a basis on which to contest the final result if they later decided to, according to Dworak.

The PAN, which has had about half as much support as the PRI in recent national surveys, pushed hard for a victory in Michoacan, hoping to use it to build momentum for 2012.

However, the party has struggled to free itself from the shackles of the drug war, which sent Calderon's approval ratings to the lowest level of his presidency this year.

Michoacan has suffered a surge in violence due to the drug war in 2011, with the murder rate up by more than a third from last year. A PAN mayor was shot dead by a group of armed men while out campaigning for the election this month.

Candidates had to avoid some areas of the state during the campaign because of fears for their own safety.

(Reporting by Dave Graham; Editing by Will Dunham)