Thousands of people enraged by power cuts during an extreme heat wave have rioted across northern India, setting electricity substations on fire and taking power company officials hostage, officials said.

The impoverished state of Uttar Pradesh has never had enough power for its 200 million people - about the population of Brazil - and many receive only a few hours a day under normal conditions, while 63 percent of homes have no access to electricity at all.

Thousands of people stormed an electricity substation on Friday night near the state capital of Lucknow, ransacking offices and taking several workers hostage for 18 hours until police intervened the next morning, state utility official Narendra Nath Mullick said.

Recent temperatures that soared to 47 degrees Celsius have caused power demand to spike at 11,000 megawatts - far higher than the state's 8,000 mega watt capacity - triggering blackouts that shut down fans, city water pumps and air conditioners.

Elsewhere, an angry crowd set fire to an electricity substation in Gonda, 180km southeast of Lucknow. It took three hours for firefighters to put out the flames.

Another substation was set on fire in Gorakhpur, 320km southeast of Lucknow.

Oppresive heat

Uttar Pradesh Chief Minister Akilesh Yadav said officials were trying to purchase power from other states, though they were also facing shortages amid the extreme heat.

Power was largely restored to most areas by Saturday afternoon, leading dozens of people who were still protesting outside Lucknow's Indira Nagar substation to go home.

Residents had been particularly angry about the power cuts after receiving reliable supplies through the Indian elections, which ended on May 16.

Since then, only some regions have been guaranteed uninterrupted power supplies, while others have received little to none.

The High Court in the city of Allahabad is now hearing a petition alleging discrimination in power distribution, and has asked the government to explain why some regions allegedly were receiving preferential treatment.

Meteorological officials said temperatures would likely remain high through at least Tuesday in Uttar Pradesh, Gujarat, Delhi and other areas of northern India.

"People are advised not to venture out of their homes," said Lucknow-based weather official J P Gupta.