Suffolk prosecutors went along with a plea deal that allowed the man accused of murdering two doctors in their Southie penthouse to keep his green card and avoid deportation — even though he admitted to robbing a bank twice.

At a September plea hearing, a prosecutor and lawyer for Bampumim Teixeira presented a joint motion to reduce the charges against the Chelsea man from two counts of unarmed robbery, to larceny from a person, according to an audio recording of the hearing obtained by the Herald.

Teixeira, who received a green card in 2010, was arrested last July for robbing $212 from a teller at Citizens Bank on Summer Street. Under questioning in that case, he admitted to jacking $600 from the same bank in 2014.

In both cases, Teixeira threatened to shoot up the bank if he didn’t get the money he demanded. Boston police charged him with unarmed robbery in both cases.

The prosecution and defense also recommended Teixeira serve 364 days in jail — nine months to serve, credit for 78 days already served, and the balance suspended for three years. They also recommended his first robbery case be marked “guilty filed,” a resolution that exempted him from immigration penalties.

A green card is a permit allowing an immigrant to live and work permanently in the U.S.

Judge Lisa A. Grant accepted the recommendations without comment or questions, according to the audio recording. Grant did not require the parties to present the recommendation, made orally, in writing.

Jake Wark, spokesman for Suffolk District Attorney Daniel F. Conley, maintained Teixeira’s sentence was “no more lenient than what would have been imposed on any similarly situated person given the same facts, circumstances and lack of criminal record.”

“When the defense counsel approached us with an offer of nine months of committed time and three years of court supervision, we believed that was a reasonable sentence,” he said.

Wark said prosecutors accepted the reduction from unarmed robbery — which under state law can be punished by life in prison and has no minimum — because an unarmed robbery case requires a grand jury indictment and has to be decided in Superior Court.

“Based on our experience, a defendant in these circumstances — that is, with no weapon, no use of actual force, and no criminal record of any kind — could very likely receive straight probation in the Superior Court,” Wark said. “The best chance at a meaningful disposition was in the Boston Municipal Court.”

Wark dismissed any suggestion that the plea deal shielded Teixeira from deportation.

“This sort of speculation only serves to detract responsibility for two murders from the only individual responsible for them — Bampumim Teixeira,” he said.

But the terms allowed Teixeira to skirt the federal law that governs which immigrants can be deported in very specific ways.

For one, federal law says immigrants can be deported if they commit an aggravated felony, which, among other ways, is defined as “a theft offense” for which the term of imprisonment imposed is at least one year. Teixeira’s 364-day sentence was a day short.

In addition, any green-card holder who is convicted of two or more crimes involving “moral turpitude” is deportable. But Teixeira’s 2014 robbery case was resolved as “guilty filed,” which allows a judge, with prosecutor and defense consent, to forgo imposing a sentence on a defendant.

Federal courts have not recognized “guilty filed” as grounds to deport an illegal immigrant.

In a statement, U.S. Immigration and Customs Enforcement said it has “no legal role in this case at this time.”

“However we will continue to monitor the matter in case his current criminal charges later affect his immigration standing,” the statement reads.