Thousands of people were evacuated from Hatteras and Ocracoke Islands in North Carolina’s Outer Banks after a construction mishap damaged the area’s main power line, plunging the islands into darkness and shutting off air-conditioners.

The outage began early Thursday morning, and when it became clear power would not quickly be restored, county governments ordered nonresidents to evacuate the islands. The evacuation order for Ocracoke went into effect on Thursday night and the order for Hatteras on Saturday morning.

Since then, at least 3,782 people and 1,485 cars have left both islands, according to a news release by the office of Gov. Roy Cooper.

Those numbers probably understate the true extent of the exodus from the Outer Banks: While Ocracoke can be reached only by sea or by air, Hatteras is connected to the mainland, which means visitors can arrive — and evacuate — in their own cars.

The problem began with construction on the nearby Bonner Bridge, according to a statement released by Dare County, which is home to Hatteras.

A transmission line that supplied power to both islands was severed when “PCL Construction, the company building Bonner Bridge, accidentally drove a steel casing” into an underground transmission cable run by the Cape Hatteras Electric Cooperative, the statement said.

The power link between the islands and the mainland is made up of three individual cables buried in the inlet. One of those three was severed by the casing and the other two were “compromised,” the cooperative said Sunday. Generators have restored power to some locations, but tourists are still not allowed on the islands.

PCL said in a statement on Sunday that it was “making the necessary repairs quickly and safely,” adding that it was working as quickly as possible to minimize the impact to the community.

“This is an incredibly frustrating time for Hatteras and Ocracoke residents and visitors and repairs have to be completed as soon as possible,” Mr. Cooper said in the statement. “Safety is our top concern, but getting power restored quickly is also key for local businesses and our tourism economy during the peak summer travel season.”

The islands are known for their beaches, campsites and fishing. Hatteras, home of the tallest brick lighthouse in the United States, and Ocracoke, once a haunt for Blackbeard the pirate, are in a string of barrier islands that make up the Outer Banks, which draw more than two million visitors annually.

Stacie Osborne, 35, visited Hatteras from Ohio and said she was in the middle of “the best family vacation we’ve ever had” when the outage hit. It was a minor inconvenience at first.

The family got supplies from a shop called the Blue Whale, but sleep was elusive.

“That first night was pretty hot,” she said. “We all changed sleeping arrangements to try to find a breeze. Some parts of the house were unbearable.”

Ms. Osborne and her family did not stay another night.

Hatteras is receiving some power from generators supplied by the electric cooperative. Ocracoke has also gained electricity from mobile generators.

Officials have asked residents to limit their power use.

The Blue Whale remains open, said Laura Fiscus, who runs the store with her family. She said the outage, particularly the lack of air-conditioning, had “made everyone grumpy.”

The real problem was that the outage drove visitors away during peak tourist season, she said, adding, “It’s hurting us small businesses very badly.”

Officials said they were unsure how long it would take to restore electricity to the islands and were still investigating the extent of the damage to the underground transmission lines.