LOS ANGELES — A California student was held on the US-Canada border Monday and accused of plotting to help a terror group and join al-Qaeda, as well as talking about attacking Los Angeles, officials said.

Nicholas Teausant, 20, who was allegedly planning to join the Islamic State of Iraq and Syria terror group, was charged with attempting to provide material support to a foreign terrorist organization.

The National Guard reservist was arrested in the early hours near the border crossing with Canada in Blaine, Washington state, said United States Attorney Benjamin B. Wagner in California.

A 23-page affidavit alleges that he traveled to the “Canadian border with the intent of continuing to travel to Syria to join the Islamic State of Iraq and Syria, a foreign terrorist organization more widely known as Al-Qaeda in Iraq.”

Teausant, a Muslim convert, had exchanged text messages with an FBI informer last year in which he asked how to get a “firework” for a planned attack on the Los Angeles subway on New Year’s Eve or New Year’s Day.

Asked what type of “firework,” he replied: “Mm the big loud one! With the biggest boom and the one that’s also compact!! Lol or at least close to it.”

In a later text message, he warned his contact, who he assumed to be sympathetic to him: “Don’t go to LA Anytime soon ..Please trust me on this…And if you do go don’t use the subway.”

In another exchange, Teausant was asked: “Which foreign country do you dislike the most?”

He answered: “I live in it.”

In messages on Instagram and other social media the suspect appeared to be surprisingly naive.

“Don’t get me wrong I despise america and want its down fall but yeah haha. Lol I been part of the army for two years now and I would love to join Allah’s army,” he allegedly posted under a pseudonym last May.

“But I don’t even know how to start,” he added.

Prosecutors allege the post was by Teausant because it appeared under a picture of him in front of a US Army Corps sign.

In August he posted: “Anyone know where I can get the ‘lone Mujahid pocket book?’” — described by the affidavit as a how-to guide for becoming a lone-wolf terrorist, available online.

Teausant faces up to 15 years in jail and a $250,000 fine if convicted, according to the LA Times.