Police arrested a Rhode Island man Thursday for the May 1 armed robbery of a Somerville bank.

Daniel Rosado, 32, was charged in federal court with one count of armed bank robbery, one count of brandishing and discharging a firearm during a crime of violence, and one count of being a felon in possession of a firearm.

The arrest comes three weeks after the FBI Boston Violent Crimes Task Force and the Somerville Police Department responded to the robbery of Middlesex Federal Savings Bank in Davis Square. They had offered a reward of $20,000 for information leading to an arrest.

The suspect exchanged gunfire with a police officer before fleeing on foot. There were no injuries.

“Today’s arrest and charges put an end to a three week search for a dangerous and reckless individual,” said U.S. Attorney Andrew Lelling in a statement. "No one should feel afraid to do the everyday, basic American errands we all need to do. But on May 1, it’s alleged that one man callously threatened the lives of dozens of innocent people who were doing just that."

As the suspect, who police identified as Rosado, fled the bank, a bystander knocked into him after seeing he was being pursued by police, causing him to drop a backpack.

"Further investigation, including forensic analysis of the backpack, linked the DNA profile found on the backpack to Rosado. A subsequent review of Rosado’s driver’s license photo matched the images of the robber captured on video surveillance at Middlesex Bank," the U.S. attorney's statement read.

Rosado has prior felony convictions that prohibit him from possessing a firearm or ammunition, including negligent operation of a motor vehicle, larceny from a person and witness intimidation, and assault by means of a dangerous weapon.