Power has been restored to New York City, after a massive outage brought the curtain down on Broadway shows, caused transport to grind to a halt as traffic lights failed, and trapped thousands of subway passengers underground on Saturday night.

The power cut came on the anniversary of a 1977 blackout which hit most of New York after a lightning strike hit a crucial substation.

This time, the problem was again related to a substation failure.

John McAvoy, the chief executive at power company Con Edison said a problem at a substation caused the 6.47pm power failure, which affected a swathe of Manhattan, covering 30 blocks from Times Square to 72nd Street and Broadway and spread to Rockefeller Centre.

Electricity was restored to customers and businesses in midtown Manhattan and the Upper West Side by around midnight, according to a statement from the firm.

New York celebrates Pride on Stonewall anniversary: In pictures Show all 15 1 /15 New York celebrates Pride on Stonewall anniversary: In pictures New York celebrates Pride on Stonewall anniversary: In pictures People dressed as flamingoes take part in the New York Pride March on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures People on stilts march in the New York Pride Parade on June 30 Reuters New York celebrates Pride on Stonewall anniversary: In pictures People stand at the roadside during the New York Pride March on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures A participant wears a hat depicting the Stonewall Inn during the New York Pride March on June 30 AFP/Getty New York celebrates Pride on Stonewall anniversary: In pictures Acitvists march in the New York Pride March on June 30 Reuters New York celebrates Pride on Stonewall anniversary: In pictures People take part in the New York Pride Parade on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures A woman dressed as the Statue of Liberty takes part in the New York Pride March on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures People take part in the New York Pride Parade on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures Marchers kiss during the New York Pride March on June 30 Reuters New York celebrates Pride on Stonewall anniversary: In pictures A marcher wears a "Mueller report" during the New York Pride March on June 30 Reuters New York celebrates Pride on Stonewall anniversary: In pictures A couple kiss during the New York Pride March on June 30 AFP/Getty New York celebrates Pride on Stonewall anniversary: In pictures A couple kiss during the New York Pride March on June 30 Getty New York celebrates Pride on Stonewall anniversary: In pictures An infant dressed as a unicorn takes part in the New York Pride March on June 30 AFP/Getty New York celebrates Pride on Stonewall anniversary: In pictures A person waves a rainbow flag in the New York Pride Parade on June 30 AFP/Getty New York celebrates Pride on Stonewall anniversary: In pictures People carry a rainbow flag in the New York Pride Parade on June 30 Getty

Mr McAvoy said the exact cause of the blackout would not be known until an investigation is completed.

The outage affected the entire subway system, closing four Manhattan stations to the public — Columbus Circle, Rockefeller Centre, Hudson Yards and Fifth Avenue at 53rd Street.

But train operators were able to manually change the signals and bring at least one car into stations so passengers could disembark, Metropolitan Transportation Authority spokesman Maxwell Young told AP.

New York City's Emergency Management Department said the A, C, D, E, F, M, 1, 2, 3, 4, 5, 6 and 7 trains had resumed running in both directions by around 2am on Sunday, following service disruptions from the blackout. Multiple street lanes between the Hudson River and Fifth Avenue had also reopened by 1.30am.

The temperature was in the low 80s (mid to high 20s Celsius) as the sun set just before 8.30pm, treating those who had streamed into the streets to one of the city's famed “Manhattanhenge” sunsets. While hot, the temperature didn't reach the highs Manhattan can hit in July, which often challenges the city's power grid.

New York governor Andrew Cuomo said no injuries were reported and praised emergency officials for their response to the blackout, which he called “unacceptable”.

“You just can't have a power outage of this magnitude in this city”, Mr Cuomo said.

“It is too dangerous, the potential for public safety risk and chaos is too high, we just can't have a system that does that, it's that simple at the end of the day.”

New York mayor Bill de Blasio was campaigning on the presidential trail in Waterloo, Iowa, when the power outage struck. His press secretary, Freddi Goldstein, tweeted just before 10pm that de Blasio cut short his Iowa visit and was headed back to the city.

The mayor commended New Yorkers for handling the blackout “with that trademark NYC grit and toughness” in a tweet.

For hours before the power flickered back on, doormen stood with torches in the darkened entrances of expensive apartment buildings along Central Park West, directing residents up flights of stairs.

Police directed traffic at junctions to a soundtrack of sirens and horns, while people in the neighbourhood known as Hell's Kitchen took it upon themselves to guide traffic in the absence of traffic lights and pedestrian signals.

In the theatre district, marquees darkened just before evening performances were set to begin. Most Broadway musicals and plays cancelled their Saturday evening shows, though some cast members staged impromptu performances in the street.

Jennifer Lopez’s concert at Madison Square Garden was cut short in the middle of her fourth song of the night, although officials at Penn Station below used backup generators to keep the lights on.

Madison Square Garden, Carnegie Hall and the Lincoln Centre for the Performing Arts were all evacuated.

Lopez later tweeted that she would reschedule the stop on her “It's My Party” tour for Monday night at the same venue.