Two Long Island men who robbed banks and gas stations to pay for their heroin habits have been arrested, Suffolk police said Friday.

In cracking the case, detectives acted on information from a witness to the Jan. 22 attempted robbery of a Commack gas station, who briefly followed the getaway car and gave police a description.

Later that day, police arrested Shabril Maxwell, 24, of Copiague, and two other suspects after a traffic stop. A fourth defendant, Robert DiGrazia, 24, of Deer Park, was arrested in that community Thursday, police said.

Police said the defendants worked alone or together in robbing or attempting to rob four gas stations and four banks between Dec. 29 and Jan. 22.

“These are people who are addicted to drugs, who are desperate and who are robbing establishments to fuel their addictions,” Deputy Police Commissioner Tim Sini said.

DiGrazia told police he robbed Roslyn Savings Bank in Huntington Station on Dec. 29 to get money for heroin, court papers said. He admitted to being the getaway driver in several holdups.

advertisement | advertise on newsday

Police said DiGrazia participated in five of the robberies; Maxwell in seven. They teamed up in four of the holdups, police said.

DiGrazia was held Friday on $150,000 cash bail or $300,000 bond after his arraignment in First District Court in Central Islip.

In court, DiGrazia’s attorney, Stephen Kunken of Commack, entered a general denial of the charges.

Maxwell was being held last night in the Suffolk jail without bail. His attorney declined comment.

Police said a black handgun was used in the gas station robberies and hand-written notes were passed to employees in the bank robberies.

On Dec. 29, a teller told police he noticed a man walk into Roslyn Savings Bank and say into his cell phone, “I’m in the bank right now. I’ve got to go,” court papers said. The robber then handed the teller a note demanding cash.

DiGrazia is charged with third-degree robbery in that holdup, and he and Maxwell are each charged with third-degree robbery for the holdup of a TD Bank in Deer Park on Jan. 11 and Bethpage Federal Credit Union in Farmingdale on Jan. 12.

Maxwell is also charged with first-degree attempted robbery of a Valero gas station in Deer Park on Jan. 17, and first-degree robbery of a Valero station in Amityville on the same day.

On Jan. 18, DiGrazia and Maxwell robbed another Valero station, in North Amityville, police said. Both are charged with first-degree robbery.

There, a witness told police that one suspect, a hood pulled over his head, bought about 10 lottery tickets and started scratching them off at the counter.

advertisement | advertise on newsday

“When the [last] customer left, he came back to the counter and told me to give him the money. I thought he had won money on a scratch-off, and I asked him how much he won,” the witness told police, according to court papers.

The robber lifted his jacket and showed a gun, then pointed it at the employee, court papers said.

DiGrazia and Maxwell are also charged with second-degree robbery for hitting the Roslyn Savings branch a second time on Jan. 19.

Maxwell, Stacey Beck, 32, of Bay Shore, and Douglas McKeefery, 30, of North Babylon, are each charged with third-degree attempted robbery of the Shell station in Commack.

With Ellen Yan