Ryan Ferguson rode into Washington with other millennials who arrived en masse after the Great Recession.

The city's burgeoning tech scene was a draw for him, and young workers infused the city with a vibrancy that touched and transformed neighborhoods like Columbia Heights, Petworth and the H Street NE corridor.

It seemed to be the start of a new era for the city and its inner suburbs. But as it turns out, it was easier to lure millennials than to keep them.

Many are now packing off for job prospects — buoyed by a stronger economy — and a higher quality of life in lower-priced cities across the nation. Some, like Ferguson, are simply moving home.

When it came time to get married and buy a house, there was no question that he would leave Washington. Today Ferguson, 28, lives with his wife, Aly, in a Boston suburb, and he's applying the lessons he learned as the general manager of the tech blog DCInno to a new job in Boston's tech scene.

A new analysis by George Mason University researchers finds that, among those already in the United States, more people are leaving the region than arriving for the first time since the Great Recession. Millennial deserters — ages 20 to 29 — are one factor. But another big one is baby boomers leaving to begin retirement life elsewhere. Families and the unemployed are also going.

This shift in trend, experts say, could have long-term consequences.

For decades, the number of people coming into the nation's capital has remained remarkably stable. The region's government agencies kept hiring through the recession and the government contracts remained a bedrock for the business community.

But historically, people tend to pack up and leave when jobs are plentiful in other cities.

The current exodus could complicate efforts to diversify the region's mix of business and wean it off its dependence on the federal government. In recent years, Washington has persuaded large corporations like Nestle and Yelp to set up offices here, and local leaders are now mobilizing to lure ­Amazon.com's second headquarters here.

Cities across the nation have wooed millennials ever since they became the largest demographic in the labor force. Local leaders have touted the city as attractive to millennials — and promoted its well-educated millennials as attractive to companies. And the latest data suggest the D.C. area is losing out as rising rents outpace growth in paychecks.

"It's definitely not gangbusters growth in wages right now," said Sonya Ravindranath Waddell, a researcher with the Richmond Federal Reserve Bank.

That often means getting a new job somewhere else is the only way to get a raise.

That was the case for George Joseph, 23, who moved to the District in early 2016 for a journalism fellowship with Atlantic Media. He was paid $12 an hour, or about $25,000 a year. He lived in a repurposed sunroom in Southeast Washington, where he wasn't on the lease, paying about $600 a month in rent.

He spoke fondly of his nine months in the District, but he said late-night cab rides occasionally depleted his bank account. The Metro stopped service after midnight last year, something that he said restrained his social life.

So he job-hopped to another journalism fellowship in New York that doubled his salary to about $50,000 a year. Now he rents a room in Brooklyn that he said is "a little nicer," for the same price he paid in the District.

"This report clearly reinforces the need to change our trajectory," said Jason Miller, chief executive of the Greater Washington Partnership, a regional economic advocacy group. "When you look under the hood at the performance of the region, our growth has been below average compared to other metropolitan areas."

Even so, the metro area's population is still growing, thanks to births and the arrival of immigrants.

"Our region has been gaining new residents steadily but has not been able to hold on to them," said Jeannette Chapman, deputy director of the Stephen S. Fuller Institute at George Mason, a center that tracks the local economy. "The region has a harder time keeping residents when the national economy picks up."

Others see little cause for alarm. The metropolitan area's fortunes have long run countercyclical to those of the rest of the nation.

"During good times in the rest of the country, people leave the Washington area because there are opportunities there," said economist Stephen S. Fuller, whose namesake Stephen S. Fuller Institute based its findings on an analysis of data collected by the U.S. Census Bureau and the Internal Revenue Service from 2000 to 2015, the latest figures available.

Before the recession, from 2003 to 2008, the region consistently saw more people leaving than arriving, as economic prosperity led to strong job growth across the country. In 2006, for example, those leaving the D.C. area exceeded the new arrivals by about 40,000.

By 2009, that dynamic had flipped. The financial crisis had sent the national economy into a tailspin. Manufacturing-depen­dent cities like Detroit were decimated and job growth across the country was sluggish. The D.C. area, though, fared comparatively better, insulated from the economic collapse by the presence of federal agencies. People stayed put, the report found, accelerating a surge in redevelopment that transformed urban neighborhoods and pushed up rents.

By 2013, the local job market started slowing. Government contractors experienced the pinch of congressionally mandated "sequestration" budget cuts, leading many to consolidate and shed jobs at a time when the national economy was heating up.

People started leaving again: The region lost about 20,000 people each year from 2013 to 2015. The losses came even among millennials.

Despite the shift, developers say they see little letup in demand for pricey apartments downtown. It could be that those moving out are being replaced by younger suburbanites moving up in the job market.

"I think that as baby boomers are retiring, the younger workforce is taking those jobs and they're not choosing to live in Sterling or Centreville," said Bob Murphy, managing principal at MRP Realty. "They're going to Arlington or the District . . . because they're getting married later and having fun on the weekends."

The District's younger populations have long been characterized by a certain transience, with people spending a few years getting to know the city before deciding to put down roots elsewhere.

The city's political workforce effectively turns over every four or eight years with the ebb and flow of national politics.

One is James "Jimmy" Sunshine, 26, a Floridian who briefly worked as a researcher in the Obama White House.

In his case, turnover was by design.

"I knew it was going to be temporary, so I tried to stay eyes wide open," he said. "The Constitution kind of puts an end date on any administration."

He recounts that when President Trump's administration swept in, many of his former colleagues left for places like New York, Boston or Seattle; places where they had grown up or had previous careers.

Sunshine now attends law school in Michigan. He says he might return some day to "help pick up the pieces" but has no immediate plans to do so.

"The people who are leaving are not the people who were born here," Fuller said. "They are eager to leave when the economic conditions wherever they grew up or went to college become more favorable."

That was the case for Ferguson, a Massachusetts native who moved to the District in January 2013 to work as a Senate staffer. He then spent a couple years at ­DCInno, but said he always considered Boston home. He and his wife closed on a house in Newburyport, Mass., in January to start their new life. His salary now is close to the $80,000 a year he made at DCInno. And their new mortgage is slightly more expensive than the rent they paid in Washington.

One big downside about Washington, he said, was that his friends kept leaving. "When you come to D.C., you know a handful of people and within a year they're all gone," he said. "So then you become friends with their friends, but then they move away, too."

"By the time I had moved away I was on like our third iteration of friends of friends of friends," he said.

Jonathan O'Connell contributed to this report.