Whitney Marshall, 25, and her friend, Eric Neff, 27, enjoy drinks after work. She is a legal fellow who has moved to the area because of work. (Ricky Carioti/Washington Post)

The recession has turned the Washington region into a magnet for young adults embarking on careers and families, putting it in the company of capitals of cool such as Seattle and Denver.

Census figures released Thursday show that the region, including the suburbs in Maryland and Virginia, gained about 7,000 people ages 25 to 34 in each of the past three years. That was the sixth-highest rate in the nation, just behind Austin and ahead of Portland, Ore.

Before the recession, the area had been losing about 8,000 young adults a year, as they flocked to metropolitan areas with lower living costs and more sunshine. It ranked 44th in the nation and was about on par with San Francisco and Boston.

The new order reflects the Washington region’s relatively resilient economy as other parts of the country floundered, racking up job losses and foreclosures after the recession began in late 2007. But some demographers also cited Washington’s emerging reputation as a cool place for young adults to live.

“It’s the economy and hipness,” said William Frey, a demographer with the Brookings Institution, who analyzed the census data comparing the 2005 to 2007 period with 2008 to 2010. “Young people are going to places that have a certain vibe. If there’s a recession, they want to ride it out in a place like that. And Washington has the extra advantage of being a government town that’s not as hard-hit by recessions as others.”

People 25 to 34 typically are starting careers, getting married and having children. In the middle part of the decade, Frey said of the census data, Washington was a stepping stone where young people got their first experience before getting jobs in regions with more affordable housing, such as Atlanta, Phoenix, Charlotte and Riverside, Calif.

But when the housing bubble popped and jobs evaporated, those regions became less attractive even as Washington retained its chief allure: jobs.

“We were doing far better than anyone else,” said John McClair, deputy director of the Center for Regional Analysis at George Mason University.

During the height of the recession, interest in the university’s public policy programs doubled and tripled from people seeking to burnish their credentials and job skills, he said.

Stacey Price, 33, closed her gift and clothing boutique in Blacksburg, Va., and moved to the District in 2008, with no promise on the horizon. Within three months, even as the recession deepened elsewhere, she found work.

“I think it’s easier for people to get jobs here,” said Price, director of Think Local First DC, a nonprofit group that supports local businesses.

Some of the region’s gain in young adults might be the result of more people staying in place, not more people moving here, said Rachel Franklin, a former Census Bureau demographer who teaches at Brown University.

“The pull is still there,” she said. “They come for the same reasons. But the push factors may have decreased.

And it’s also cool. Some have probably moved to D.C. because they’ve heard it’s a cool city to live in, though not to the extent of Portland.”

Bert Sterling, who scours census statistics to compile lists of the best places to live — and who lives in Portland — said he expects the Washington area eventually will revert to a more traditional role, as a place to establish a career and eventually move on.

“Washington is known as a center for power and, during the recession, has taken on the image of a place where the jobs are,” he said. “I haven’t heard anyone say Washington is hip and cool. But I don’t know if you want your seat of government to be too cool and quirky.”

Researchers Magda Jean-Louis and Ted Mellnik contributed to this report.