A Long Island teenager who pleaded guilty to trying to join al-Qaeda affiliate Ansar al-Sharia earlier this year is expected to be sentenced to 30 years in prison by a federal judge, prosecutors said Wednesday.

Although 18-year-old Justin Kaliebe of Babylon and Bay Shore, N.Y., pleaded guilty to attempting to provide material support to terrorists in February, the Brooklyn U.S. Attorney’s Office first made the case public Wednesday.

Kaliebe admitted before U.S. Magistrate Judge A. Kathleen Tomlinson that he tried to travel to Yemen so he could join al-Qaeda in the Arabian Peninsula, also known as Ansar al-Sharia.

Kaliebe wanted to join the al-Qaeda offshoot “for the purpose of … waging violent jihad,” according to U.S. Attorney Loretta Lynch’s office.

“Kaliebe attempted to turn his back on his country and align with radical terrorists. His goal was to travel overseas to wage violent jihad against Yemeni and U.S. forces opposed to al-Qaeda. Firmly committed to this plan, he found both inspiration and guidance in the online teachings of al-Qaeda leaders, including Usama [Osama] Bin Laden,” Lynch said in a statement announcing the unsealing of the complaint against Kaliebe. “While the Internet has made worlds of knowledge available to all, unfortunately it is also used as a platform for al-Qaeda and other terrorist groups to spread their poisonous propaganda. Terrorists continue to exploit this free and open medium to persuade United States citizens and others to carry out attacks, both here and abroad. We must and will use every tool to identify and disrupt potential attackers before they strike.”

Kaliebe unwittingly told undercover officers that he tried for two years to travel abroad and wage jihad, according to court papers.

The recordings showed Kaliebe was aware of the legal troubles he would face if caught, saying in one conversation that “the crime that they would charge people like us with” was conspiracy “to kill, maim and kidnap in foreign countries.”

The teen’s plans were to join up with Ansar al-Sharia and fight the Yemeni army and “those who are fighting against the Sharia of Allah ... whether it’s the U.S. drones or the, their puppets, in the Yemeni army ... or, who knows, if American agents or whatever, U.S. Special Forces ... who they got over there,” according to court papers.

When an undercover agent asked Kaliebe if he was afraid to die, he responded, “I wanna ... it’s what anyone would want, any believer would want.”

Kaliebe started saving money for his trip to Yemen in July 2012, and used the funds to pay for a passport and buy an airline ticket to Oman. His plan was to travel to Yemen after landing in Oman.

Kaliebe swore his allegiance to al-Qaeda and al-Qaeda in the Arabian Peninsula on Dec. 26, 2012, according to the U.S. Attorney’s Office.

“I pledge my loyalty, allegiance and fidelity to the Mujahedeen of Al-Qaa'idah in the Arabian Peninsula and its leaders, Shaykh Abu Baseer Nasir Al-Wuhayshi and Shaykh Ayman Al-Zawahiri, hafidhahum Allah! May Allah accept this from me and may he allow me to fight in his cause til the day that I leave this dunya,” he wrote.

Kaliebe’s actions were monitored by undercover NYPD officers with the department’s intelligence division.

The Long Island teen was nabbed by FBI agents and NYPD Intelligence Division officers as he tried to board a flight to Oman at John F. Kennedy International Airport on Jan. 21. He pleaded guilty Feb. 8 to attempting to provide material support to terrorists.

FBI Assistant Director-In-Charge George Venizelos said Kaliebe was serious about joining al-Qaeda, but fortunately law enforcement disrupted his plans.

“Kaliebe was equipped to travel overseas and fight jihad abroad. He set the wheels in motion – convinced of his well-thought-out plan – but didn’t get very far,” Venizelos said. “The FBI, along with our law enforcement partners, will seek out those who pledge allegiance to terrorists and terrorist organizations throughout the world, and we will continue to work together to disrupt their evil plans.”

Kaliebe's sentencing date has yet to be set, but prosecutors indicated that U.S. District Judge Arthur Spat will sentence the teen to 30 years in prison.