21 Savage may be deported, and not because he's ineligible to stay in the United States ... it's because of Donald Trump.

We now understand MOST of what went down with 21's arrest and looming deportation. Here's how it goes.

Sources directly connected to the case tell TMZ ... the decision to arrest and deport 21 Savage was made months ago by the Atlanta bureau of ICE. At that time, ICE decided it would arrest Savage and hold him without bond until he could be deported.

As for why ICE wanted Savage held without bond, we've learned they incorrectly believed 21 had a felony conviction, which would have disqualified him from being able to post bond. As we reported, 21's 2014 drug conviction was vacated and sealed in the Fall -- which effectively erases it -- but court records weren't updated, so all ICE saw was the conviction.

Now, this is super weird ... we've learned just days ago ICE headquarters in Washington D.C. got involved in the case, and when they did, ICE had already figured out 21 was not a felon and therefore should have been released on bond. Our sources say ICE in D.C. IGNORED the fact that the conviction was erased and doubled down, saying 21 should NOT be released. No one we've spoken to has any idea why D.C. took such a position when it was not supported by the facts.

Keep reading ... we're getting to Trump.

We've confirmed ICE was on the scene with various other local and federal law enforcement agencies when 21 was arrested on Super Bowl Sunday with a plan to arrest him. We're told ATF first took 21 into custody and literally handed him over to an ICE agent on the spot.

Our ICE sources say they had no other involvement in the other arrests at the scene ... they were only there to arrest Savage. It is unclear why ICE needed to be part of that operation ... why didn't they just go to 21's home and arrest him in the months prior to the sting?

As we reported, 21's lawyers went to court Tuesday and convinced a judge to bond 21 out. As for next steps, 21's application to stay in the U.S. will be processed, and it's virtually certain it will be approved because he qualifies on every count. He has dependents in the country, he has no convictions, and he's been here more than 10 years. There are no obstacles in his way ... EXCEPT TRUMP.

Turns out Trump changed the immigration policies from Obama and Bush. We're told Trump's marching orders are to deport people who have a pending visa application -- even if it's a slam dunk -- and they can come back if and when it's approved.

We've learned, before 21 Savage was released Tuesday, ICE agents told him they would drop deportation proceedings if he voluntarily left the country. We're told he passed and will fight to stay.

BTW ... 21 filed his application to stay in the U.S. in 2017 and it takes around 4 years for ICE to process it, so the stakes are high.