WASHINGTON — Walter R. Walsh, who captured gangsters as an FBI agent in the 1930s and went on to train Marine Corps snipers and become the longest-lived Olympian, has died.

Walsh died Tuesday at his home in Arlington, Virginia, his son Gerald Walsh confirmed Thursday. Walsh, who would have turned 107 on Sunday, suffered a minor heart attack a few weeks ago and his health deteriorated, Gerald Walsh said.

Walsh, who first honed his shooting skills by picking clothespins off a clothesline with a BB gun as a child, began his FBI career in 1934 and was soon chasing gangsters across the United States.

On one day in 1935, he helped capture gangster Arthur “Doc” Barker in Chicago and fatally shot a second gangster, Russell “Rusty” Gibson.

Two years later, Walsh was in Bangor, Maine, on the trail of the Al Brady Gang.

Al Brady, Clarence Lee Shaffer Jr. and James Dalhover had traveled to Bangor in search of guns.

The gang, which was wanted for three murders and a series of grocery store and bank robberies, had heard that guns could be purchased in Bangor with no questions asked, according to a story in the Press Herald.

But they drew attention when they tried to buy a machine gun.

Dalhover arranged to buy the weapon from Everett ‘’Shep’’ Hurd, the owner of Dakin’s Sporting Goods Co.

But Hurd, who told Dalhover to pick up the machine gun in a week or so, was suspicious of the men. He went to the Maine State Police, who alerted the FBI.

A dozen FBI agents quietly assembled in Bangor, and they were ready when Dalhover came back to the store to make his purchase.

Walsh’s role was to pose as a salesman, and when Dalhover came inside, Walsh arrested him.

Outside the store, Shaffer fired through the glass and wounded Walsh in the chest and hand before being shot by Walsh and collapsing on the cobblestones outside the store.

Brady, the FBI’s “Public Enemy number 1,” was gunned down after he pulled out a handgun and fired off four rounds, none of which hit their target.

Several years ago, Walsh returned to Bangor at age 100 for a re-enactment of the gun battle.

Walsh joined the Marine Corps Reserve in 1938 and became active duty in 1942, training snipers in North Carolina. In 1948 he competed in the London Olympics, placing 12th in the men’s 50-meter free pistol event at age 41.

Though he didn’t medal, decades later Walsh went on to set an Olympic record.

In 2013, at the age of 105 and 321 days, he became the longest-lived Olympian, eclipsing a record set by gymnast Rudolph Schrader. He was also the FBI’s oldest retired agent.

Walsh was born May 4, 1907, in New Jersey. He got his first rifle, a .22-caliber Mossberg, when he was about 12 according to a profile in the American Rifleman. By the time he graduated from Rutgers University’s law school he had won a series of honors. He continued to shoot until recently, his son said.

“Sunday if you could have got somebody to take him to the range he probably would have gone. The last thing he was shooting was shotgun because the pistol was getting a little hard for him to hold as steady as he used to,” Gerald Walsh said.

In addition to his son Gerald, Walsh is survived by another son, Walter Walsh Jr., and three daughters: Kathleen Reams, Linda Walsh and Rosemary Haas. His wife, Kathleen Barber, predeceased him.