Three Massachusetts men pleaded guilty to orchestrating a sophisticated multistate ATM robbery spree, netting them $500,000, including more than $170,000 stolen from a credit union ATM.

David Barker, 39, Efrain Montero, 41, and Jonathan Santos, 35, of Lawrence, pleaded guilty to indictments charging them with the burglary and attempted burglary of 13 ATMs and commercial businesses, according to the Essex District Attorney’s Office.

Assistant District Attorney Philip Mallard said the men scouted for ATM locations in Massachusetts, New Hampshire and Vermont.

The men traveled in a stolen van to targeted ATMs and used tools to access them. Wearing masks and dark clothing, two of the three men neutralized the alarm and security system, while the third man looked out for police. After cutting wires to the ATM’s security system, they waited and listened on a scanner to be sure that police had not been alerted.

In addition to stealing from nine bank ATMs starting in October 2015, the trio robbed the Service Credit Union ATM at Lebanon, N.H., on Feb. 14, 2016; the Central One Federal Credit Union ATM at Shrewsbury, Mass., on May 5, 2016, and the Northeast Credit Union ATM at Berwick, Maine on June 16, 2016.

While the robbers stole tens of thousands of dollars from the ATMs, they siphoned $172,000 from the Northeast stand-alone ATM housed in a kiosk, Mallard said.

Just six weeks after the Northeast theft, two of the robbers were arrested. Police arrested the third man later. Investigators were able to link the men to the ATM crimes with digital, forensic and physical evidence.