An explosion at a Con Edison facility in Astoria, Queens, sent a gigantic flash of blue light across the city sky Thursday night, causing power outages and stalling trains.

Incredibly, there were no immediate reports of injuries.

“Damn, I thought a UFO hit Con Ed,” Astoria resident Joe Calderone said. “I thought the world was ending.”

Mayor de Blasio’s office said the sudden bolt of lighting was caused by an electrical surge at a substation — and added, tongue in cheek, that, no, there was no threat from outer space.

“*Not* aliens,” de Blasio spokesman Eric Phillips tweeted. “Blown transformer at Queens Con-Ed facility. Scattered power outages, including LGA.”

The NYPD also weighed in, tweeting that there was “no evidence of ­extra­terres­trial activity.”

The flash, which many said made it suddenly look like daytime, was sparked by a fire at the facility at about 9 p.m.

A short transmission dip followed, causing lights to flicker and temporarily turn off in parts of Queens, officials said.

The blast frightened nearby residents, who immediately feared a bombing.

Astoria resident Anna Mayo said she heard a “boom boom boom” and “ran out of our apartments like we were running for our lives.”

Another neighbor also said he ran from his house after the explosion, fearing the worst.

“All I saw was a bright blue flame, like the sky lit up,” Gordon Thomas said. “I thought it got bombed. I ran away as fast as could.”

La Guardia Airport’s backup generator was tripped by the dip in power, said Con Ed spokesman Bob McGee.

The airport temporarily suspended outgoing flights, but service was quickly restored.

The MTA also said that No. 7 trains were temporarily suspended between 74 Street-Broadway and Main Street because of a loss of power. Service resumed soon after the disruption, but delays on the line lingered for hours.

“There was a brief electrical fire at our substation in Astoria which involved some electrical transformers and caused a transmission dip in the area,” Con Edison posted on Twitter. “We’re currently investigating the cause.”

The NYPD, Office of Emergency Management and FDNY were also investigating as city residents marveled at the sight and posted images online.

Videos and photos of the light-blue sky spread online as some compared it to scenes from movies.

“Independence Day and Ghostbusters are trending,” Danielle Solzman tweeted. “I have no punchline.”