A lawyer for James ­“Whitey” Bulger is urging a federal appeals court to order the judge assigned to the gangster’s upcoming murder and racketeering trial to step aside, citing his close ties to the US Department of Justice and the FBI.

In a motion filed Tuesday, Bulger’s lawyer, J.W. Carney Jr., said that if the US Court of Appeals for the First Circuit fails to grant his request, Bulger’s trial “will go forward under a dark cloud that threatens to taint the integrity of every ­aspect of the proceedings.”

Carney asked the court to ­issue a writ of mandamus, an order forcing US District Judge Richard G. Stearns to vacate his earlier rulings in which he rejected Bulger’s request that Stearns disqualify himself from the case.

Bulger, 83, a longtime FBI informant, is scheduled to stand trial in June on charges of participating in 19 murders, racketeering, and extortion. He has vowed to take the stand in his own defense and contends he was promised immunity from prosecution by Jeremiah T. O’Sullivan, a federal prosecutor who led the New England Organized Crime Strike Force during the 1980s and who died in 2009.

Get Fast Forward in your inbox:

Forget yesterday's news. Get what you need today in this early-morning email.

Carney argued that Stearns’s ability to be impartial is questionable because he was a top-ranking prosecutor in the US attorney’s office in the 1980s, when Bulger alleges he was being protected by the government, and also is a close friend of FBI director Robert S. Mueller III.

The defense wants to call Stearns as a witness at the trial to question him about Bulger’s immunity claim.

“It is critical that this trial be free from even the slightest hint of a government coverup,” Carney wrote in his motion.

Stearns, who was randomly assigned to preside over the case, denied two requests by Bulger to disqualify himself, ruling that he was not involved in any cases related to Bulger while a prosecutor and that there was no basis to call him as a witness.

Federal prosecutors, who opposed the defense push for a new judge, have accused ­Bulger of intentionally trying to delay his trial.

During a brief telephone inter­view Wednesday, Steve Davis, whose 26-year-old sister Debra Davis was allegedly strangled by Bulger in 1981, said he fears Bulger will never stand trial.

“This is just his way of stalling this,” Davis said.

Bulger fled just before a ­January 1995 indictment after being tipped by his former FBI handler. He was captured in June 2011 in Santa Monica, Calif., after more than 16 years on the run.

Bulger’s sidekick and fellow FBI informant, Stephen “The Rifleman” Flemmi, also claimed that the pair had been promised immunity from prosecution in exchange for providing information against the Mafia.

But Flemmi claimed it was a corrupt FBI agent who promised them immunity, with the condition that they not kill anyone.

In 1999, a judge ruled that the FBI did give Bulger and Flemmi tacit approval to commit crimes and even protected them from prosecution, but that there was no formal ­immunity agreement. Flemmi, who is serving a life sentence for 10 murders, is scheduled to testify against Bulger at his ­upcoming trial.

Anthony Cardinale, a ­Boston lawyer who worked to expose the FBI’s relationship with Bulger and Flemmi while representing former New ­England Mafia boss Francis “Cadillac Frank” Salemme, said it is legally impossible for a prosecutor to give someone immu­nity for murder.

“What justice system on the face of this earth would ­approve that and still be called a justice system?” Cardinale said.

A spokeswoman for the US attorney’s office declined to comment on Bulger’s appeals court filing.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.