A Boston cop helping hurricane victims in Puerto Rico stumbled upon a home-grown crime while lending a hand: A brazen illegal immigrant living in the Bay State allegedly stole the identity of a Puerto Rican police officer.

Jose Perez-Jimenez, 29, of Guatemala was arrested twice in Massachusetts while posing as officer Hector Carrasquillo, admitting later that he purchased the cop’s name, Social Security number and birthdate to pose as a United States citizen, according to Lowell police, who ultimately nabbed him.

“Perez readily admitted to us that he has used the Carrasquillo name in the past and remembers being stopped by the Dunstable PD for a mv infraction,” wrote Lowell police officer Brian Keefe in a Nov. 29 arrest report.

The audacious identity heist proves that anyone can be a victim in a pernicious scheme in which illegal immigrants use stolen identities to fraudulently obtain Massachusetts driver’s licenses, said Saugus police officer James Scott.

Scott created a course called “Identifying the Imposter” that teaches law enforcement officials how to spot identity thieves using fraudulently obtained state IDs.

“This is a great example of the program coming full circle,” said Scott.

The 29-year-old Perez-Jimenez used Carrasquillo’s identity when he was arrested on Aug. 24, 2016, and was charged with an insurance violation and driving with a suspended license. He used it again when arrested on Nov. 16, 2016, and charged with trying to fill a fraudulent prescription, according to police reports.

Carrasquillo mentioned the identity theft to Boston police officer Joshua DeLa­Rosa while the two were on patrol in Puerto Rico in early November. DeLaRosa, who has taken a course on how to recognize fraudulently obtained state IDs, searched Criminal Justice Information Services.

“He found the attached impostor with a suspended license here in Mass. along with a m/v warrant under the trooper’s name,” said Scott. “Imagine the hassle Trooper Carrasquillo would have trying to fix his revoked or suspended license issue in Massachusetts.”

But the Bay State crime busting didn’t stop there.

Perez-Jimenez’s last known residence was in Lowell, according to criminal records, and Lowell police detective Carlos Mercado was also volunteering in Puerto Rico at the time.

Mercado took a statement from Carrasquillo and the Lowell Police Department arrested Perez-Jimenez in late November on an old warrant.

“Detective Mercado was informed of the arrest, as he is involved in the ongoing investigation,” wrote Lowell officer Keefe.