A California man dubbed the "American Taliban" following his capture on a battlefield in Afghanistan in 2001 was released from prison Thursday after serving 17 years, authorities confirmed, amid allegations of his continued adherence to extremist views.

The Federal Bureau of Prisons confirmed that John Walker Lindh, 38, who was serving his sentence at the federal prison in Terre Haute, Indiana, was no longer in its custody.

Lindh, who was convicted of providing support to the Taliban, was freed three years early for good behavior, according to CNN, which first reported the release.

President Donald Trump said Thursday afternoon that he heard about Lindh's imminent release two weeks ago and sought legal advice in an effort to stop it. "I don't like it at all," Trump told reporters.

He claimed that Lindh had not given up his support for terrorism, but that authorities had to release him.

"Am I happy about it? Not even a little bit." he said.

But, Trump warned, "We will be watching him – and watching him closely."

Lindh, the son of a Justice Department lawyer who grew up in a San Francisco suburb, was captured in a battle with Northern Alliance fighters in late 2001. Video footage showed Lindh – weak, dirty and almost incoherent from apparent battlefield injuries – laying on a cot in a detention center.

Start the day smarter:Get USA TODAY's Daily Briefing in your inbox

A CNN camera filmed Lindh, in halting English, telling American forces how he had wound up at a detention camp in northern Afghanistan and survived a Taliban uprising there that killed hundreds of prisoners and CIA officer Mike Spann.

Secretary of State Mike Pompeo slammed the release, calling it "unexplainable and unconscionable.”

Pompeo said in an interview with Fox News that Lindh "still is threatening the United States of America, still committed to the very jihad that he engaged in that killed a great American and a great CIA officer. There’s something deeply troubling and wrong about it."

Lindh's release was also opposed by Spann's family. The CIA officer's father, Johnny Spann, called Lindh a traitor on Twitter, charging that he "knew they were going to attack America, stayed with them, training in (al-Qaida) camps." He appealed to President Donald Trump to block the release.

Lindh was not accused of participating in the killing but was present during the attack, according to authorities.

Lindh admitted to participating in the revolt near Mazar-e Sharif, Afghanistan, but prosecutors did not say that he had a role in Spann's death.

His freedom comes with court-imposed restrictions, including software on his internet devices. He is required to only use English online and to surrender his passport. He also is banned from viewing or possessing extremist material, and is required to undergo mental health counseling.

Lindh, raised a Catholic, converted to Islam as a teenager after seeing the film "Malcolm X" and went overseas to study Arabic and the Koran. In November 2000 he traveled to Pakistan and from there made his way to Afghanistan where he was a volunteer at an al-Qaida training camp.

He was with the Taliban at the time of the 9/11 attacks and was captured in the U.S.-backed retaliatory raids on Afghanistan.

In his trial in 2002, Lindh pleaded guilty to serving in the Taliban army and carrying weapons but denied taking up arms against the U.S.

"I did not go to fight against America, and I never did," Lindh told the court. "I have never supported terrorism in any form, and I never will. ... I made a mistake by joining the Taliban. Had I realized then what I know now, I would never have joined them."

In the run-up to Lindh's release, Foreign Policy reported that two government documents it obtained expressed concerns about Lindh's extremist views. One document, from the National Counterterrorism Center, found that as of 2016 Lindh "continued to advocate for global jihad and to write and translate violent extremists texts," the magazine reported.

According to Foreign Policy, the document, which cites various Federal Bureau of Prisons intelligence summaries, claims that in March of last year, Lindh “told a television news producer that he would continue to spread violent extremist Islam upon his release.”

The TV producer is not identified, no specific statements are quoted, and there is no public record that Lindh has participated in media interviews, according to the magazine.

The Bureau of Prisons said it cannot comment specifically on Lindh's case, but noted that it has policies and procedures for monitoring communications of inmates with known or suspected ties to domestic and foreign terrorism and "shares information with law enforcement as appropriate."

The Bureau of Prisons, citing studies by its staff, says it "has found that many inmates have turned away from radicalized ideology in prison based on self-study or due to participation in programming or sentence length."

"While we are aware of a small number of this population who have returned to BOP custody, none have returned to BOP custody for terrorism-related charges," the bureau said.