The Washington region scrambled Saturday to recover from a sudden and violent storm that killed at least five people, uprooted thousands of trees and left more than 1.3 million homes and businesses without power in Maryland, Northern Virginia and the District.

Virginia, D.C. and Maryland officials declared a state of emergency as power companies across the region warned that it might take as long as a week to fully restore electricity. More storms were possible Saturday evening, though they were not expected to be as widespread or severe as Friday’s.

The storm, which took at least 13 lives across the eastern United States, caused widespread damage, leaving more than 3 million people without power.

The storm’s ferocity made light of the trappings of urban order. In Montgomery County alone, 500 of the county’s 800 traffic lights were out. Drivers dodged fallen trees, downed wires and pools of standing water.

As late as 4 p.m., Arlington officials characterized 911 service as sporadic, and advised residents to call or personally go to stations to report emergencies.

As of 5 p.m. Saturday, 1.2 million customers remained without power in the region. Pepco was reporting 420,000 customers without electricity in the District and neighboring parts of Maryland. That represented more than half of the 778,000 homes and businesses that Pepco serves.

Dominion Virginia Power was reporting that about 383,000 customers in northern Virginia had no power, almost half the homes and businesses in northern Virginia.

And at Baltimore Gas and Electric, 406,000 customers were powerless, a third of its customers in a service area that includes parts of Prince George’s and Montgomery counties.

Authorities rushed to open libraries, swimming pools and cooling centers to give residents respite from the sweltering heat, which was expected to break the 100-degree mark for the second consecutive day Saturday.

The Anacostia Public Library stayed open late Saturday, one of five branches in the city that extended its hours. Shaneka Griffin, 22, brought her young daughter because the infant couldn’t fall asleep in their sauna-like home. “I brought my baby here so she could say, ‘Goodnight,’ ” she said.

Malls were jammed as people sought power outlets to charge their phones and computers, and long lines were reported at gas stations that still had power to run their pumps.

Virginia Gov. Robert F. McDonnell (R) said Friday night’s storm triggered the largest non-hurricane power outage in state history and forced the closure of 250 secondary and rural roads because of fallen trees.

“This is a very dangerous situation for Virginia,’’ McDonnell said, urging residents to check on elderly neighbors and those without electricity.

“Recovery will be difficult,’’ he said. “It’s going to be days before power is fully restored in the commonwealth.”

Falling trees killed at least four people, including two in the Springfield area of Fairfax County. One tree struck a car at Old Keene Mill Road and Bauer Drive, killing the male driver, said Officer Don Gotthardt, a Fairfax County police spokesman. A 90-year-old woman, lying in bed, was killed when a tree fell on her house, authorities said.

A falling tree also apparently killed a 71-year-old woman in her bed in Silver Spring, Montgomery police said. In Anne Arundel County, a 25-year-old Edgewater man was killed when a tree fell on his car as drove on Harwood Road.

In Northwest Washington, a person died touching a live electrical wire, said Pepco authorities, who urged people to be cautious around the many down lines.

In addition to the five local fatalities, four deaths were reported elsewhere in Virginia — two each in Albemarle and Bedford counties. Meanwhile, four people were rescued and one person was still missing after a boat swamped and capsized last night off Chesapeake Beach in Calvert County, Maryland State Police said.

Maryland Gov. Martin O’Malley (D) said he had heard from President Obama, who was at Camp David in Maryland’s Catoctin Mountains this weekend. “I was afraid he was calling to say his power was out,” O’Malley joked, “but he was calling to check on us.”

Obama also called McDonnell and the governors of Ohio and West Virginia to get updates on storm cleanup and offer the federal government’s help.

Maryland officials announced that if another round of storms materializes, they may close the Bay Bridge on Saturday evening due to potentially unstable scaffolding on the bridge.

Amtrak halted train service Saturday between Washington and Philadelphia, and Metrobus riders faced delays on more than two dozen routes as drivers attempted to navigate around downed trees, downed power lines and large pools of standing water, said Metro spokesman Dan Stessel.

Metrorail service opened on time Saturday, but at least five stations were operating on back-up power — Forest Glen, Takoma, Twinbrook, College Park and Clarendon.

Crews worked to replace a section of track near Twinbrook after a metal pole from a tent used by a nearby car dealership hit a section of electrified rail just before 11 p.m., leaving a gash.

“It was like a knife slicing through butter,” Stessel said about the incident.

The storm left behind expensive messes for families, too.

Bill Callaghan, 59, gazed ruefully at the two 50-foot-tall oak trees that had crashed down in his Springfield back yard Friday night.

Callaghan said he was out checking on his dogs about 11 p.m. when everything suddenly went quiet. Then the wind picked up, and the trees around him began to sway dangerously. He ran into his home, shepherding his wife and dogs into the basement.

“That’s when I heard the big snap and crunch,” he said. “We felt the house shudder.”

At least one tree struck the corner of his house, most likely ruining a $10,000 roof that had just been installed Wednesday, Callaghan said. While he waits for an estimate of costs for the cleanup, he said, he plans to take his family to a hotel.

Across the river in Potomac, Sarah and John Barpoulis and their three teenage children had narrowly averted disaster Friday night thanks to their Labradoodle, Gracey, whose frantic digging at the carpet alerted them to the oncoming storm.

As they made their way to the basement, they heard a loud crack: Part of a pine tree had sheared off and fell onto a bedroom, crashing through its ceiling and releasing a shower of pink fiberglass insulation.

At least 20 neighbors rallied to their aid Saturday, arriving with a generator, power tools and a pickup truck to haul away debris, saw off pieces of the tree and remove furniture from the destroyed bedroom. By early afternoon, the scene had nearly returned to normal.

“We’re extremely fortunate to have such a close neighborhood,” Sarah Barpoulis said. “I can’t believe how people have come and helped us.”

Around the region, people sought refuge in the malls, restaurants and coffee shops that had their lights on and air conditioning humming. Families tried to save food from spoiling in warming refrigerators, and long lines formed at the few gas stations that still had power. Cars waited 10 deep at an open Exxon in Chevy Chase, where some customers hunting for fuel had driven from as far away as Rockville and Germantown.

At Sibley Hospital in the District, maintenance and landscaping workers used chainsaws to cut apart a felled tree blocking the emergency room entrance.

Nurses and technicians who worked a 12-hour shift Friday saw a wave of new births — some appeared to be induced by the heat — then left the hospital near midnight only to find all roads home blocked with trees and debris. Several returned and slept at the hospital until their shifts began again Saturday. Others who learned that they had no electricity at home stayed to work overtime instead.

D.C. Mayor Vincent C. Gray, who is on a seven-day trade mission to China, issued a statement offering his thanks to emergency first responders “who have been out there all night and will be out all day today in the heat.”

At its height, the storm knocked out power for more than 1.5 million homes and businesses across the region, a number that fell Saturday as power companies dispatched crews. More crews were expected to arrive Monday from as far away as Texas and Florida.

As of 3 p.m. Saturday, Pepco reported more than 420,000 customers without power in Montgomery and Prince George’s counties and the District.

Pepco spokesman Clay Anderson said the outages since Friday night were twice as bad as those during Hurricane Irene in 2011.

Dominion Virginia Power reported at midday that about half its Northern Virginia customers — about 419,000 homes and businesses — remained without power. Fairfax County appeared hard-hit.

In the area served by Baltimore Gas and Electric, more than 418,000 homes and businesses lacked electricity as of 1 p.m. Saturday. The company serves 1.2 million customers in an area that reaches southward into parts of Prince George’s and Montgomery Counties.

Many gas stations, lacking power to run their pumps, were closed. At one open station, an Exxon outlet on North Washington Street near the Rockville Town Center, vehicles idled in a line that stretched several blocks long in the blistering heat.

Waiting on foot with two empty 5-gallon containers was Gayle Day, 42, of Silver Spring. “I drove all the way on Viers Mill Road and this was the only gas station open,” she said, recalling how she used her car’s GPS to guide her from gas station to gas station.

People such as Alison Sistrunk found themselves trolling around in their cars or, in her case, a white SUV, in search of food and coffee.

“The only thing we have working is the telephone,” said Sistrunk, a Bowie resident who was among the BGE customers without power Saturday morning. “I have battery-operated candles for light, but the entire area is down.”

Meanwhile, the Washington Suburban Sanitary Commission issued mandatory water restrictions Saturday for all residential and commercial customers in Montgomery and Prince George’s counties because the storms had knocked out power to WSSC’s two water filtration plants and other facilities.

The restrictions might remain in place for days, officials said. Even after the electricity is back, it will take time to pump water back into holding tanks, said WSSC spokesman I.J. Hudson. And more damaging storms might be on the way, he added.

“We’re not out of the woods yet, there are still electrical outages,” Hudson said. “Don’t water the flowers, postpone using the dishwasher, and take a short shower if you’re going to take a shower.” Hudson also urged customers to not to flush toilets after every use.

Tap water remains safe to drink, Hudson emphasized, but he said customers may notice low pressure in some areas.

DC Water said it had experienced no storm-related problems.

Girl Scouts from Troop #287 in Southeast Washington decided Saturday to beat the heat and escape power outages at a water park in Alexandria, only to find sign out front of Cameron Run Regional that said “Closed No Power.”

“We’ve got plenty of sun, but no fun,” said Renee Glenn, 39, of District Heights. She wondered how they would stay cool as temperatures approached triple digits.

She and another mother whipped out their smart phones to figure out whether a water park in nearby Fairfax was open.

“If I don’t jump in some water soon, I’m going to roast,” said her daughter, Lehymia, 15.

Lori Aratani, Michelle Boorstein, Beth Chang, Pam Constable, Aaron Davis, Annie Gowen, Hamil R. Harris, Anita Kumar, Luz Lazo, Carol Morello, Joe Stephens, Lena Sun, Susan Svrluga, Ted Trautman, Karen Tumulty, John Wagner, Ovetta Wiggins and Mihir Zaveri contributed to this report.