A hacker who helped Islamic State by providing the names of more than 1,000 US government and military workers as potential targets was sentenced on Friday to 20 years in prison.

The sentence was much higher than the six-year term sought by defense lawyers, who argued their client, Ardit Ferizi, meant no real harm and was not a true Isis supporter.

“He was a nonsensical, misguided teenager who did not know what he was doing,” said public defender Elizabeth Mullin. “He has never embraced Isil’s ideology.”

Ferizi, a 20-year-old native of Kosovo who was arrested last year in Malaysia, is the first person convicted in the US of both computer hacking and terrorism charges. He admitted hacking a private company and pulling out the names, email passwords and phone numbers of about 1,300 people with .gov and .mil addresses. Isis published the names with a threat to attack.

At Friday’s sentencing hearing, Ferizi struggled to explain why he did it, when asked directly by US district judge Leonie Brinkema for an explanation. He said that it all happened very quickly.

“I feel so bad for what I did,” he said. “I am very sorry for what I did, making people feel scared.”

Prosecutors asked for the maximum sentence of 25 years.

Assistant US attorney Brandon Van Grack said: “The defendant’s conduct has indefinitely put the lives of 1,300 military members and government workers at risk.”

He disputed the idea that Ferizi’s crime was a whim. Before turning over the names to the “Islamic State hacking division” last year, he operated a website devoted to propagating Isis propaganda. In online conversations, Ferizi defended Isis, and when he gave the 1,300 identities to the group, he knew he was putting them in would-be terrorists’ crosshairs, Van Grack said.

“This was a hitlist. The point was to find these individuals and hit them, to ‘strike at their necks’,” Van Grack said, mimicking the language Isis used when it published the names.

Van Grack quoted a letter from one of the victims, who said she had an easily identifiable name and was now nervous when she interacted with Muslims, something she felt guilty about. And Van Grack cited another terrorism case in northern Virginia, in which the defendant, Haris Qamar, allegedly used a hitlist, similar to the one Ferizi created, to stake out the homes of two neighbors in the town of Burke.

Mullin countered that nobody on the list has actually been harmed, and said much of the information Ferizi helped disseminate was publicly available anyway.

Court papers describe a difficult life for Ferizi, who was nominally raised as a Muslim and was just four years old when Nato airstrikes forced Serbian forces to withdraw from the territory, which subsequently became independent. Ferizi’s uncle was murdered and his father was kidnapped during the war, according to letters written by Ferizi’s family.

As a teenager, Ferizi got in trouble for hacking into Kosovar government databases, but he avoided jail. Ferizi went to Malaysia to study cybersecurity, but continued his hacking activities and developed worsening mental health problems, defense lawyers said.

He met an Isis recruiter on the internet while he was trying to expose online pedophiles, his lawyers said.