A drug deal gone awry set off a chain of events that led two well-to-do American teen tourists to be implicated in the savage slaying of an Italian police officer, police said Saturday.

The suspects, identified as San Francisco residents Gabriel Christian Hjorth, 19, and Finnegan Lee Elder, 18, spent their second day in a Rome jail after being grilled about the death of Vice Brigadier Mario Cerciello Rega, who police say was knifed eight times by one of the teens Friday, close to the posh hotel by the Tiber River where the two were staying.

Italian police said Saturday that the teens confessed to their role in the killing of Rega, 35, a newlywed just back from his honeymoon.

The pair, classmates in ritzy Mill Valley were allegedly furious that instead of cocaine, a drug dealer pedalled “a different substance” when they set up a buy in Trastevere, a popular tourist spot in the city known for its nightlife.

Following the deal, the two Americans allegedly swiped their dealer’s bag and cellphone and fled, according to surveillance footage.

Carabinieri police said the teens demanded $112 and a gram of cocaine from the dealer to return the bag.

The robbery victim told authorities he’d arranged a meeting in nearby Prati with the Americans to retrieve his belongings.

At about 3 a.m. Friday, Rega and another plainclothes officer were dispatched to Prati after the alleged drug dealer reported the theft to police.

Once the officers arrived, a brawl broke out.

That’s when Elder allegedly stabbed Rega eight times, while Hjorth repeatedly punched the other cop who responded, police said.

“Even though the officers identified themselves as being Carabinieri police officers,” the teens “didn’t hesitate to engage in a struggle, culminating in the mortal wounding,” Italian police said.

Outside of law enforcement, Rega was known to his charity work with the homeless and sick.

Rega’s death outraged citizens and local officials, who vowed justice would be served.

“Hoping that the killer of our poor Carabiniere never gets out of prison, I remind do-gooders that in the United States, whoever kills risks the death penalty,” tweeted Interior Minister Matteo Salvini, who is also in charge of state police, another national Italian police corps.

“I’m not saying we’re get to that, but yes to a life in prison (in labor, obviously).”

Italy, like the rest of Europe, doesn’t have the death penalty.

As of late Saturday local time, the Americans —who were travelling without their parents — still hadn’t been formally charged.

Elder’s lawyer, Francesco Codini, said his client exercised his right not to answer to questions at a Saturday hearing. Natale-Hjorth’s lawyer refused to speak to reporters.

With Post wires