ALBANY, N.Y. — Platinum-selling rapper Ja Rule left an upstate New York prison this morning after serving most of his two-year sentence for illegal gun possession and headed straight into federal custody in a tax case.

U.S. Marshals escorted the 36-year-old musician out of Mid-State Correctional Facility at 6:30 a.m., but it wasn’t immediately clear where he’ll serve time in the tax case.

The rapper, who had been in protective custody because of his celebrity, has some time remaining on a 28-month sentence for tax evasion.

Ja Rule, whose real name is Jeffrey Atkins, may have fewer than six months left and may be eligible for a halfway house, defense attorney Stacey Richman said. An order to pay $1.1 million in back taxes is one of the main reasons he wants to get back to work, she said.

Ja Rule scored a Grammy Award nomination in 2002 for the best rap album with “Pain is Love.” He also has appeared in movies, including “The Fast and the Furious” in 2001 and “Scary Movie 3” in 2003.

In the gun case, New York City police said they found a loaded .40-caliber semiautomatic gun in a rear door of Ja Rule’s car after it was stopped for speeding, and he pleaded guilty in 2010.

He admitted in March 2011 in federal court that he failed to pay taxes on more than $3 million he earned between 2004 and 2006 while he lived in Saddle River, N.J.