A Methuen man accused of breaking into a mosque there and stealing some cash and electronics was caught by police after himself becoming a victim of an armed robbery for one of those items.

Police said the imam at Selimiye Mosque told detectives two computers, a video camera, network router and donation box full of money were stolen from the property sometime Thursday night or early Friday morning. 

Later that day, officers responded to a report of an armed robbery on Railroad Street. There, police said detectives learned two men robbed William Ortiz, 38, after watching him try to break into the donation box with a large coat hanger “in broad daylight.”  

Ortiz was then placed under arrest, with the stolen safe returned to the mosque, police said. He now faces a charge of breaking and entering at night to commit a felony and a single count of larceny over $250. 

Police also later arrested two suspects in the armed robbery: Josue Marrero, 29, and Julio Medina Pimental, 32, both of Lawrence. Investigators said they found more than 54 grams of heroin and a stolen, loaded handgun after searching their home. 

Both men assorted drug trafficking, firearms and armed robbery charges, police said. Marrero also had several outstanding warrants on his record. 

“This is a very unfortunate situation that resulted in two criminal incidents and three people arrested,” Chief Joseph Solomon said in a statement.

“Thankfully, our Methuen Police detectives conducted an aggressive investigation and were able to quickly solve these incidents without further disruption to our community.”