Federal authorities said they were investigating the possibility it was an act of terrorism.
A U.S. official speaking on condition of anonymity identified the gunman as 24-year-old Muhammad Youssef Abdulazeez of Hixson, Tennessee, and said he was believed to have been born in Kuwait, though it was unclear whether he was a U.S. or Kuwaiti citizen.
"Lives have been lost from some faithful people who have been serving our country, and I think I join all Tennesseans in being both sickened and saddened by this," Gov. Bill Haslam said.
Within hours of the bloodshed, law officers with guns drawn swarmed what was believed to be Abdulazeez's house, and two females were led away in handcuffs.
A dozen law enforcement vehicles, including a bomb-squad truck and an open-sided Army green truck carrying armed men, rolled into the Colonial Shores neighborhood of Hixson, and police closed off streets and turned away people trying to reach their homes.
The shootings took places minutes apart, with the gunman stopping his car and spraying dozens of bullets first at a recruiting center for all branches of the military, then apparently driving to a Navy-Marine training center 7 miles away, authorities and witnesses said. The attacks were over within a half-hour.
Authorities would not say how the gunman died. FBI agent Ed Reinhold said Abdulazeez had "numerous weapons" but would not give details.
The Marine Corps said four Marines were killed, all of them at the Navy-Marine training site, and a fifth Marine was wounded in the leg but not seriously hurt. Also, a police officer was shot in the ankle, Mayor Andy Berke said.
The names of the dead were not immediately released.
Reinhold said authorities were looking into whether it was domestic or international terrorism or "a simple criminal act."
In Washington, President Barack Obama pledged a prompt and thorough investigation and said the White House had been in touch with the Pentagon to make sure military installations are being vigilant.
"It is a heartbreaking circumstance for these individuals who served our country with great valor to be killed in this fashion," he said.
Vice President Joe Biden likewise said: "Their families have already given a lot to the country, and now this."
The shootings began at the recruiting center on Old Lee Highway, where a shot rang out around 10:30 or 10:45 a.m., followed a few seconds later by more fire, said Sgt. 1st Class Robert Dodge, leader of Army recruiting at the center.
He and his comrades dropped to the ground and barricaded themselves in a safe place. Dodge estimated there were 30 to 50 shots fired. Doors and glass were damaged at the neighboring Air Force, Navy and Marine offices, he said.
Law enforcement officials told recruiters that the gunman stopped his car in front of the recruiting station, shot at the building and drove off, said Brian Lepley, a spokesman with the U.S. Army Recruiting Command in Fort Knox, Kentucky.
The recruiting center sits in a short shopping strip between a cellphone business and an Italian restaurant, with no apparent special security.
The gunman opened fire next at the Navy Operational Support Center and Marine Corps Reserve Center Chattanooga.
The center is in an industrial area that includes a Coca-Cola bottling plant. The two entrances to the fenced facility have unmanned gates and concrete barriers that require approaching cars to slow down to drive around them.
Marilyn Hutcheson, who works at Binswanger Glass across the street, said she heard a barrage of gunfire around 11 a.m.
"I couldn't even begin to tell you how many," she said. "It was rapid-fire, like pow-pow-pow-pow-pow, so quickly. The next thing I knew, there were police cars coming from every direction."
She ran inside, and she and other employees and a customer waited it out with the doors locked. The gunfire continued with occasional bursts for what she estimated was 20 minutes. Bomb squads, SWAT teams and other local, state and federal authorities rushed to the scene.
"If it was a grievance or terroristic related, we just don't know," she said.