The Twin Cities economy grew at its fastest pace in nearly a decade last year, and real estate was the big driver.

The U.S. Commerce Department reported Tuesday that real GDP, the total value of goods and services adjusted for inflation, grew by 3.9 percent, adding more than $7 billion in economic activity.

Almost a third of the growth was in real estate, rentals and leasing, thanks to an improved housing market and low rental vacancy.

“We have one of the lowest vacancy rates in the United States,” said Toby Madden, an economist at the Federal Reserve Bank of Minneapolis. “Home sales were up in August 2012 over August 2011 by 12 percent. Sale prices were up 16 percent.”

Minneapolis-St. Paul didn’t move from its spot as the 13th-largest metropolitan economy in the United States, behind Seattle and ahead of Detroit. GDP grew in 305 of the nation’s 381 metropolitan areas.

A healthy market: About one-third of last year’s economic growth in the Twin Cities was driven by real estate transactions, accounting for $30 billion in activity, the Commerce Department reported. Home sales were up 12 percent over a year ago and prices were up 16 percent, a local economist said. Above, home buyer Stephen Blatnik, left, and his real estate agent, Herb Bacal.

But the pace of growth in the Twin Cities was well above the national average, better than such Midwestern cities as Chicago, Milwaukee, St. Louis and Kansas City, and propelled Minnesota into the position of having the fifth-fastest-growing economy in the nation.

Banking, insurance and real estate led the way. But the strength of food companies, medical devices, retail and construction illustrate the Twin Cities’ great strength — economic diversity, said Michael Langley, president of Greater MSP, an economic development group.

“We’re not a one-horse town,” Langley said. “We have other major industry sectors that are also showing growth, including manufacturing of both durable and nondurable goods, but also business services and professional services around our headquarters here.”

Signs of life in housing and real estate led to 8 percent growth for real estate, rental and leasing, accounting for nearly $30 billion in economic activity in the Twin Cities. Finance and insurance posted an 8.1 percent gain, accounting for $21.4 billion.

“We’ve come out of the housing crisis in better shape than a lot of regions because we had not overbuilt,” Langley said.

Since home sales and prices continued to rise in 2013, that sector of the economy has likely kept up its growth.

Unemployment in the metro area was 4.9 percent in July, compared with a national average of 7.4 percent.

With a population of 3.4 million including 125,000 people across the river in Wisconsin, the Twin Cities metropolitan area accounts for three-fourths of Minnesota’s economic activity.

“The Twin Cities metro area is the driver of Minnesota’s GDP,” said Louis Johnston, an economist at the College of St. Benedict and St. John’s University. “And of course that’s built in part on stuff that’s going on in other parts of the state — it’s an interactive process.”

Manufacturing grew by 5.9 percent in 2012, but it isn’t clear whether industry has kept up its growth in 2013.

“It’s still growing but probably not as fast as it was before,” Madden said.

It’s even less clear whether increasing manufacturing output is translating into jobs. Factory employment in the metro area has declined in 2013, just as it has across the state, even as companies have pivoted to take advantage of the oil boom in North Dakota.

“The mix of what’s being produced in Minnesota is changing,” Johnston said. “We’re able to take advantage of what’s going on in the Bakken” oil field.

In the rest of Minnesota, Mankato’s and St. Cloud’s economies grew slightly faster than the Twin Cities, and Rochester was not far behind. However, the economy in Duluth-Superior shrank in 2012 by 2 percent, or about $167 million. The weakness there came from declines in mining output and financial services.

Across the region, Bismarck, N.D., was the fastest-growing economy, followed by Peoria, Ill., and Fargo. The 10 largest U.S. metropolitan areas, accounting for 34 percent of national GDP, averaged 3.1 percent growth in 2012 after growing 1.9 percent in 2011.