"The night they told me, 'You are not allowed to go,' I thought I [might] never go," Abdi said.
His children also wondered whether they would ever get to the United States, according to the imam.
On Sunday afternoon, however, the Abdi family landed at Salt Lake City International Airport, ending a journey that included two more delays after leaving Kenya.
They were met by a crowd of about 100 supporters who cheered and clapped loudly as the family walked into the baggage claim area. Many rushed forward to hug the imam, and a few held signs with greetings to the family and thanks to the lawyers.
At a news conference at the airport with his attorneys, Abdi who believes he was put on a federal no-fly list expressed gratitude to everyone who had worked to bring him home.
And when asked after the conference what he planned to do now, Abdi said, "The first thing I am going to do is thank everyone. This is a gift from God."
Abdi has lived in Utah for the past six years. His wife and two of his children have visas; three of his other children are legal immigrants.
His lawyers filed a lawsuit Friday in Salt Lake City's U.S. District Court against five federal agencies in hopes of bringing Abdi home as soon as possible. The suit says Abdi was put on the federal government's no-fly list after he arrived in Kenya.
The Salt Lake Tribune could not reach officials with the defendant agencies Sunday.
No judicial action has been taken in the suit; the lawyers got the assistance of the U.S. attorney's office in Utah to get the imam on a plane.
"We worked with many other federal agencies to help facilitate getting him on flights and getting him home," Melodie Rydalch, spokeswoman for the office, said Sunday.
Those agencies included the Department of Homeland Security and the U.S. Justice Department.
On Saturday, Abdi and his family members flew to Los Angeles, where they missed their connection because of his lengthy questioning by customs officials, Abdi said. He said their journey included one more delay Sunday, when his wife for an unknown reason was not permitted to board the plane in California.
However, the pilot of the American Airlines plane stepped in, Abdi said.
"The American pilot said, 'We will not separate the family,' " he said. After a 20-minute delay, his wife was allowed on the plane.
The lawsuit filed Friday says that Abdi's constitutional rights were violated and that he was discriminated against because of his race, religion and ethnicity. Lawyers say the government had no reason to believe Abdi presented a threat to the U.S. and that he has no criminal record.
According to the lawsuit, the government added Abdi to the watch list in 2014 under a classification that allowed him to fly but required that he undergo extra security measures. Court papers say he filed a redress request with the Department of Homeland Security in 2016, but his status was not changed.
The imam's travel trouble came on the heels of President Donald Trump's executive orders to block or restrict refugees and travelers from six predominantly Muslim countries from entering the United States.
Two federal appeals courts have rejected the so-called "Muslim bans," and the Department of Justice has asked the Supreme Court to consider the issue. Kenya is not one of the Muslim-majority countries targeted by Trump.