TERRE HAUTE, Ind. (AP) — The California man who became known as the “American Taliban” after his capture on an Afghanistan battlefield in late 2001 has been released from prison.

John Walker Lindh, 38, was released Thursday from the federal prison in Terre Haute, Indiana, according to the federal Bureau of Prisons. Lindh spent more than 17 years in prison after pleading guilty to providing support to the Taliban.

The plea deal called for a 20-year sentence, but Lindh is getting out a few years early for good behavior.

His release was opposed by the family of Mike Spann, who was killed during an uprising of Taliban prisoners in Afghanistan shortly after interrogating Lindh.

A judge recently imposed additional restrictions on Lindh’s post-release supervision, amid concerns that Lindh still harbors radical ideology. Lindh initially opposed but eventually acquiesced to the restrictions, which include monitoring software on his internet devices; requiring that his online communications be conducted in English and that he undergo mental health counseling; and forbidding him from possessing or viewing extremist material, holding a passport of any kind or leaving the U.S.

Probation officers never explained why they sought the restrictions but it is clear that authorities retain misgivings about Lindh. In 2017, Foreign Policy magazine cited a National Counterterrorism Center report that Lindh “continued to advocate for global jihad and to write and translate violent extremist texts.”

On Wednesday, NBC reported that Lindh, in a letter to a producer from Los Angeles-based affiliate KNBC, wrote in 2015 that the Islamic State is “doing a spectacular job” and “is clearly very sincere and serious about fulfilling the long-neglected religious obligation to establish a caliphate through armed struggle.”

Lindh, now 38, converted to Islam as a teenager after seeing the film “Malcolm X,” and went overseas to study Arabic and the Quran. In November 2000, he went to Pakistan and from there made his way to Afghanistan and joined the Taliban. He met Osama bin Laden and was with the Taliban on Sept. 11, 2001, when al-Qaida terrorists attacked the World Trade Center and the Pentagon.

Lindh was captured in a battle with U.S.-allied Northern Alliance fighters in late 2001. He was present when a group of Taliban prisoners launched an attack that killed Johnny Micheal “Mike” Spann, a CIA officer who had been interrogating Lindh and other Taliban prisoners.

He was brought to the U.S. to face charges of conspiring to kill Spann and providing support to terrorists. Eventually, he struck a plea bargain in which he admitted illegally providing support to the Taliban but denied a role in Spann’s death.

Lindh served roughly 17 years and five months of his 20-year sentence, including two months when he was in military detention. Federal inmates who exhibit good behavior typically serve 85 percent of their sentence.

Lindh’s release has drawn criticism, including from Spann’s family. His daughter, Alison Spann, said on Twitter that she asked President Donald Trump to block Lindh’s release. She called Lindh a traitor and his early release “a slap in the face.”

In March, the legislature in Alabama, where Spann grew up, adopted a resolution calling Lindh’s release “an insult” to Spann’s “heroic legacy and his remaining family members.”

Mike Spann’s mother, Gail Spann, told reporters at the time that Lindh could have saved her son’s life had he warned him about the looming prisoner revolt.

“He chose not to because he was a Taliban. He’s a traitor to our country. He could have had an opportunity to save a great man that actually saved a lot of lives that day,” she said.

Republican Alabama Sen. Richard Shelby and Democratic New Hampshire Sen. Maggie Hassan also expressed concern, in a letter last week to the Bureau of Prisons.

“We must consider the security and safety implications for our citizens and communities who will receive individuals like John Walker Lindh who continue to openly call for extremist violence,” they wrote.

Associated Press writer Kimberly Chandler contributed to this report from Montgomery, Alabama.