John Walker Lindh was 20 years old when he was captured.

John Walker Lindh, the American captured in Afghanistan in 2001 fighting for the Taliban, was freed early from federal prison on Thursday after serving 17 years amid concerns he might still harbor extremist views.

US President Donald Trump told reporters at the White House that he had asked government lawyers whether the release could be stopped but said nothing could be done.

"What bothers me more than anything else is that here's a man who has not given up his proclamation of terror, and we have to let him out. Am I happy about it? Not even a little bit," Trump said.

Lindh, who was 20 years old when captured, left the prison in Terre Haute, Indiana, on Thursday morning, the Federal Bureau of Prisons said. He had been sentenced to 20 years after pleading guilty in 2002 to charges of supplying services to the Taliban and carrying an explosive during the commission of a felony.

Lindh is among dozens of prisoners to be released during the next few years after being captured in Iraq and Afghanistan and convicted of terrorism-related crimes following the attacks on the United States by al Qaeda on Sept. 11, 2001.

Leaked US government documents published by Foreign Policy magazine show the federal government as recently as 2016 described Lindh as holding "extremist views."

US Secretary of State Mike Pompeo called Lindh's release "unexplainable and unconscionable."

"There's something deeply troubling and wrong about it," he said on Fox News on Thursday morning.

"What is the current interagency policy, strategy, and process for ensuring that terrorist/extremist offenders successfully reintegrate into society?" asked U.S. Senators Richard Shelby and Margaret Hassan in a letter to the Federal Bureau of Prisons.

The bureau said in a statement that it does not share details of specific inmates' release plans but that it does have policies for monitoring parolees with ties to terrorism.

During his supervised release, Lindh will not be allowed to possess any internet-capable device without permission from his probation officer, and any such device must be monitored continuously, according to court documents.

He is not allowed to hold a passport, communicate with known extremists or have any online communications in any language other than English unless approved. He also must undergo mental health counselling, court documents showed.

Lindh's parents, Marilyn Walker and Frank Lindh, did not respond to requests for comment and Lindh's lawyer, Bill Cummings, declined to comment.

U.S.-born Lindh converted from Catholicism to Islam as a teenager. At his sentencing in 2002, he said he travelled to Yemen to learn Arabic and then to Pakistan to study Islam.

Lindh said he volunteered as a soldier with the Taliban, the radical Sunni Muslim group that ruled most of Afghanistan from 1996 to 2001, to help fellow Muslims in their struggle or "jihad." He said he had no intention "to fight against America" and never understood jihad to mean anti-Americanism.

Lindh told the court he condemned "terrorism on every level" and attacks by al Qaeda leader Osama bin Laden were "completely against Islam."

But a January 2017 report by the U.S. government's National Counterterrorism Center, published by Foreign Policy, said that, as of May 2016, Lindh "continued to advocate for global jihad and to write and translate violent extremist texts."

NBC News reported that Lindh wrote a letter to its Los Angeles station KNBC in 2015 expressing support for Islamic State, saying the Islamic militant group was fulfilling "a religious obligation to establish a caliphate through armed struggle."

