A Jamaica man turned prospective Islamic State fighter pleaded guilty in federal court Tuesday for his role in attempting to support the terrorist organization.

Ali Saleh, 25, pleaded guilty at the Brooklyn federal courthouse to two counts of attempting to provide material support to the Islamic State, also known as ISIS, the U.S. Attorney’s Office for the Eastern District of New York said.

“Ali Saleh was persistent in his efforts to become a foreign fighter, but his persistence did not exceed the diligence of law enforcement,” said FBI Assistant Director-in Charge William Sweeney. “The defendant went to great lengths to attempt to travel to the Middle East, while funding other foreign fighters in the process. As the FBI’s Joint Terrorism Task Force continuously strives to protect citizens from potential terrorist threats, today’s plea depicts one of the many efforts to achieve this goal.”

Saleh was arrested after repeatedly trying to travel to the Middle East to aid ISIS as a foreign fighter, according to court filings. Beginning in 2013, Saleh became interested in the conflict in Syria and swore an oath of allegiance to ISIS online.

In August 2014, Saleh wrote, “Let’s be clear the Muslims in the khilafah [caliphate] need help, the one who is capable to go over and help the Muslims must go and help,” and made an airline reservation to travel from New York to Turkey that same day. His trip was eventually halted when his parents took away his passport.

Later that year, Saleh began communicating with an ISIS supporter in Mali via an online messaging platform and wired $500 to fund the person’s travel to Syria.

In July 2015, Saleh purchased fireworks containing explosive powder and hid them in his car’s trunk. Law enforcement agents later located a cellphone belonging to Saleh that contained an ebook detailing how one could create a bomb using explosive powder from fireworks. On July 24, Saleh booked a flight from New York to Egypt, which borders Libya, but was denied boarding at Kennedy Airport. He attempted to skirt travel restrictions by boarding at airports in New Jersey, Pennsylvania and Indiana but was also denied.

After Saleh attempted to dodge U.S. air travel restrictions by trying to take a train from Cleveland to Canada and flying to the Middle East, law enforcement intervened.