BOSTON — A federal judge on Tuesday refused to recuse himself from the trial of mobster James “Whitey” Bulger, flatly rejecting a challenge to his impartiality by Bulger’s lawyers.

The defense argued in a motion filed last month that Bulger — who is awaiting trial for his alleged role in 19 murders — should not be prosecuted because he was promised immunity by a representative of the federal government for past or future crimes while he was a top-echelon FBI informant.

Bulger’s lawyers asked Judge Richard Stearns to step down from the case because he was a top federal prosecutor in the 1980s, when Bulger allegedly was committing crimes with impunity while also acting as an informant.

The defense said Stearns would try to shield his former colleagues and could not be impartial. The defense also said it may call Stearns as a witness as part of a motion to dismiss the charges based on Bulger’s claim that he was granted immunity.

In a written order, Stearns said he had no doubt about his ability to remain impartial, noting that as an assistant U.S. attorney, he was never involved in the prosecution of a case in which Bulger was a subject or target. Stearns also blasted the defense for questioning his impartiality.

“It would be institutionally irresponsible for me, or for that matter, any other judge, to enter a recusal in a case where a party has chosen to make untrue accusations in the possible hope of subverting that process, or at the very least, forcing a delay of a trial by injecting a diversionary issue into the proceedings,” Stearns wrote.

Stearns also wrote that “no reasonable person” could doubt his impartiality. Bulger’s lawyer, J.W. Carney Jr., zeroed in on that assertion when asked about Stearns’ ruling following a pre-trial hearing in Bulger’s case Tuesday.

Carney noted that Stearns headed the criminal division of the U.S. attorney’s office during part of the 1980s, at a time when Bulger was allegedly committing crimes but not being prosecuted for them.

“Reasonable members of the general public will be free to express their own views” on that, Carney said.

Stearns said in his ruling that it would be pointless for Bulger’s lawyers to call him as a witness on Bulger’s immunity claim.

“Because at no time during my service as an AUSA did I participate in or have any knowledge of any case or investigation in which defendant was a subject or target, I have nothing of a relevant or material nature to offer with regard to this case or any claim of immunity,” Stearns wrote.

Bulger, the former leader of the notorious Winter Hill Gang, fled Boston in 1994 after receiving a warning through his former FBI handler that he was about to be indicted.

Now 82, Bulger was apprehended last year in Santa Monica, Calif., after 16 years on the run. Former Boston FBI Agent John Connolly Jr. was convicted of racketeering in 2002 for tipping off a Bulger associate about the impending indictment.

During a pretrial hearing in U.S. District Court Tuesday, Magistrate Judge Marianne Bowler said she will unseal some documents in the case in response to motions by Bulger’s lawyer to lift a protective order.

Bowler said she will give prosecutors two weeks to indicate which of the hundreds of thousands of pre-trial discovery documents in the case should remain sealed.

After that, she will give Bulger’s defense team a chance to object. Then, she’ll review the documents herself and decide which should remain sealed and which Bulger’s defense team can share with outside lawyers, pre-trial focus groups or other third parties.

Carney said the protective order now in place prohibits him from sharing the documents with anyone other than lawyers in his firm or witnesses. He said the order has hindered his ability to discuss trial strategy or get outside feedback on the case.