Emadeldin El-Sayed agreed to leave after facing possible deportation for writing that he ‘wouldn’t mind serving a life sentence for killing’ Donald Trump

An Egyptian flight school student who was arrested in Los Angles over a Facebook post in which he mused about killing Donald Trump agreed on Friday to leave the US of his own accord.

Emadeldin El-Sayed, 23, who had been a student at the Universal Air Academy in LA, and was facing possible deportation, appeared in an immigration court in the city on Friday shackled and wearing a yellow jail jumpsuit.

According to the Associated Press, immigration authorities agreed to let Sayed return to Egypt voluntarily instead of deporting him, as long as he departs the US by 5 July. Sayed has not been charged with a crime but had his visa revoked.

The case has sparked an intense debate over free speech in the US, where the Republican frontrunner’s anti-Muslim rhetoric has offended many followers of Islam.

Sayed’s Facebook post on 3 February related to Trump’s plan to ban foreign Muslims from entering the US. It has since been taken down, however the student’s attorney, Hani Bushra, confirmed his client’s message was to the effect that he “wouldn’t mind serving a life sentence for killing this guy” and that he would be “doing the world a favor”.

According to court documents, the Facebook post was seen by Alex Khatib, the owner of the flight school, who immediately contacted the FBI. The FBI then passed the matter to the Secret Service, which is tasked with protecting Trump because he is a leading Republican candidate for president.

On two separate occasions on 4 and 5 February the Secret Service interviewed Sayed, and on the second interview they also searched his home and his computer, although the US attorney’s office declined to press charges.

He was not arrested until 11 February, when Sayed received a call from his flight school telling him to come in.

In court documents Khatib said he had been told by “federal agents” that Sayed’s visa had been revoked by the State Department, and that he should revoke the I-20 as well, meaning Sayed was then in violation of his terms of admission into the US.

When Sayed arrived, two agents from the Immigration and Customs Enforcement agency (ICE) were waiting to take him into custody. His I-20, which gives him leave to remain in the country, had been revoked by the flight school. He has been in an Orange County jail since.

“It’s beyond silly,” Bushra said in an interview prior to Friday’s hearing. “This was a post that was done foolishly … he was upset with Mr Trump’s comments about Muslims.” He pointed out that the Secret Service had not detained Sayed, and did not consider him a threat.

Bushra said his client wanted to “get some of his money back and leave so he can go back to his own country”.

The attorney added that Sayed was devastated by the events. “He’s invested so much with his school,” he said, adding that the $40,000 tuition and sundry expenses were “a huge investment” for his client. “He had hopes of becoming a pilot, his instructors say he was a good guy. He feels like his reputation has been tarnished unfairly.”

In a statement, a spokesperson for the ICE said Sayed was taken into custody purely “for allegedly violating the terms of his admission to the United States,” meaning the revocation of the I-20 leave to remain.

A federal official familiar with the case said it wasn’t unusual for students to have their I-20 rescinded – for a variety of reasons, including academic performance – and that sometimes such students are then detained by the ICE before their deportation can be arranged.

In an emailed statement, Bushra’s law firm said Friday they had also asked that their client be released while he is preparing for his departure. However, the law firm said the application was denied.

“That means Emad will leave the country under ‘safe guards’ which means he has to be escorted from jail directly to New York, where he will take the Egypt Air flight to Cairo,” the statement said. “We are now trying to work on expediting this process as fast as possible.”

Associated Press contributed to this report