Authorities said they had taken into custody Eulalio Tordil, a 62-year-old officer in the Department of Homeland Security's Federal Protective Service, which protects US government facilities.
Police in Montgomery County, Maryland, outside the US capital, made the announcement on Twitter without offering further details after a manhunt that lasted several hours.
In the morning hours, gunfire broke out at the Westfield Montgomery mall in Bethesda, with one man killed and two people wounded.
A second shooting later at a supermarket in nearby Aspen Hill, Maryland left one woman dead.
More From This Section
"This continues to be a very active investigation," Montgomery County Police Captain Paul Starks told reporters before Tordil's capture.
"We're still looking at the possibility that these shootings here (in Bethesda) and the shooting in Aspen Hill are related (and) were committed by the same suspect."
Schools in the vicinity were briefly asked to keep children in place "out of an abundance of caution," the official said. The schools later decided to proceed with normal dismissal.