SAN DIEGO — U.S. authorities twice tried to deport a black man who was fatally shot by police in a San Diego suburb this week but his native Uganda refused to take him.

Then last year, he stopped reporting to immigration authorities as required under terms of his freedom and it’s unclear whether the government made any attempt to find him.

An explanation for why Alfred Olango remained in the country lies in a 2001 U.S. Supreme Court ruling that generally prohibits the detention of foreign nationals for more than six months if deportation is unlikely.

The nation’s highest court said in the 5-4 decision that holding people indefinitely only because no country will take them violates the constitutional right to due process.

Some of the thousands of immigrants who have been released after being ordered deported went on to commit crimes, making the Zadvydas vs. Davis decision a lightning rod for critics who say it illustrates a broken system.

Olango, who arrived in the United States as a refugee in 1991, was among those who committed crimes.

He was ordered deported by an immigration judge in 2002 following his conviction for transporting and selling narcotics, U.S. Immigration and Customs Enforcement told The Associated Press on Thursday. However, Uganda wouldn’t take him back after multiple requests, leading to his release in 2003 under an order of supervision.

Olango later was convicted on a weapons charge in Colorado, sentenced to nearly four years in prison and ordered to be deported in 2009 after his release.

Uganda again refused to issue travel documents allowing him to return.

Olango was told to check in monthly with immigration authorities and did so until February 2015. Immigration and Customs Enforcement spokeswoman Virginia Kice was unaware of any efforts to find him.

A message seeking comment from the Ugandan Embassy in Washington was not immediately returned. The country accepted 11 people who were deported from the U.S. during the 2015 fiscal year but it was unclear how many were denied.

John Sandweg, a former ICE director who left the agency in 2014, said U.S. officials had little recourse once Olango stopped checking in. Under the Supreme Court decision they could have held him only six months and then would have to let him go because failing to report to immigration authorities is not a crime.

“When you have a recalcitrant country who won’t take that individual back — won’t give permission to return them to their own country or denies their identity, denies that they’re actually citizens of that country — ICE has no choice but to release those individuals,” Sandweg said.

He said sanctions and other measures, such as limiting visas, are possible but he couldn’t recall a time that the U.S. exerted serious pressure when he held senior positions at the Homeland Security Department from 2009 to 2014. In some cases, the U.S. lodged formal protests known as demarches.

ICE says it released 2,166 immigrants with criminal histories due to the Supreme Court ruling during the 2015 fiscal year, 2,457 the previous year and 3,652 the year before that.

Olango, 38, was shot and killed Tuesday by police in El Cajon who responded to calls from his sister saying her brother was acting erratically and wandering into traffic. Officers say he ignored repeated requests to raise his hands and was shot multiple times when he pulled what turned out to be a 4-inch electronic cigarette device from his pocket and pointed it at one officer while taking a “shooting stance.”

The shooting sparked protests in the city of 100,000 people, which is home to large numbers of Iraqi and Syrian refugees.

Taxin reported from Santa Ana, California.