India's Congress party trailed in fourth place as vote counting neared its end in Uttar Pradesh on Tuesday, a bitter election blow to Rahul Gandhi who had staked his political future on reviving his party's fortunes in the populous northern state.

Gandhi, scion of the Nehru-Gandhi dynasty that ruled India for most of its 65 years of independence, had campaigned tirelessly to revive his party in the politically crucial state where it has not ruled for 22 years.

The campaign, which thrust him into the rough and tumble of the state's politics - even sleeping in villagers' huts - was widely seen as a test of his fitness to take the reins of Congress from his ailing Italian-born mother, Sonia.

The Uttar Pradesh election was also seen as a measure of Rahul's ability to emerge from the shadows of government and replace Manmohan Singh as prime minister if Congress and its coalition allies retain power in national elections due in 2014.

The socialist Samajwadi Party (SP) looked set to win the largest number of seats in Uttar Pradesh, where the population of 200 million people makes it larger than Brazil.

There was also mostly disappointing news for Congress from four other states that went to the polls over the past month. It was heading for a loss in Punjab and Goa and neck-and-neck with a rival in Uttarakhand, but was set to win in the far-flung northeastern state of Manipur.

It has been a disaster for the Congress, it's an even bigger disaster for Rahul Gandhi and the Gandhi family, said political analyst Amulya Ganguli.

They were banking on success in these elections, hoping to get at least four out of five states. It has gone exactly the opposite way. It shows that there is no charisma left in the Gandhi family.

ROADBLOCK TO REFORM The party's setbacks in Uttar Pradesh and Punjab could make it harder for Singh's already weakened coalition government to pursue reforms that could shore up the country's economic growth, which has slipped below 7 percent.

Battered by a string of corruption scandals and inflation, Singh last year was forced to shelve a flagship reform to open the supermarket sector to foreign direct investment (FDI) by global retailers such as Wal-Mart, in the face of protests from even within his government.

Following the state assembly election results, the unpopular reforms might be postponed to some extent like FDI in retail and the deregulation of diesel prices, said N.R. Bhanumurthy, an economist at the National Institute of Public Finance and Policy, a Delhi-based think tank.

It breaks the confidence of the government.

With partial results in for 398 of the 403 assembly seats in Uttar Pradesh, Congress was leading in just 34, according to the Election Commission. That was an improvement on the 22 it won in the last poll, but a far cry from the 100-plus it had predicted.

The Uttar Pradesh result means a return to power for Mulayam Singh Yadav, a former wrestler who first became chief minister there in 1989, when Rahul's father, Rajiv, was still alive. However, his party may fall short of an absolute majority and may seek a coalition with Congress to rule the state.

Congress spokesman Abhishek Manu Singhvi defended Gandhi's electioneering despite the disappointing results.

Not even Rahul Gandhi's worst enemies, political or otherwise, suggest that his leadership was lacking. He was outstanding, he said. He's gone to every nook and cranny, he's provided the spirit, the euphoria, the leadership - if it doesn't translate, then it doesn't translate.

(Writing by John Chalmers; Additional reporting by Annie Banerji, Arup Roychoudhury and Manoj Kumar; Editing by Robert Birsel)