The release took place on the night towards Saturday Swedish time, a few hours after a decision from a federal court that it should be done.
Justice prevailed, but it has taken far too long. This should not have taken three months, he said outside the detention center in the state of Louisiana where he spent his time in captivity.
Khalil was arrested on March 8 outside his residence on Manhattan, without being charged with a crime.
President Donald Trump's government wants to deport him for his participation in pro-Palestinian demonstrations at Columbia University in New York. The 30-year-old Khalil is now expected to return to New York to be reunited with his wife, who has given birth to the couple's first child while her husband was imprisoned.
Judge Michael Farbiarz, who made the decision on the release, had already previously ruled that Khalil should be released, but he gave the US government a deadline to appeal the decision by Friday. The judge set bail at one dollar, equivalent to just under ten kronor, which Khalil has paid.
Khalil is not accused of direct crimes in connection with the protests at Columbia University in New York.