Malware researcher Marcus Hutchins has pleaded guilty to two counts of creating and selling a powerful banking malware, ending a long and protracted battle with U.S. prosecutors.

Hutchins, a British national who goes by the online handle MalwareTech, was arrested in August 2017 as he was due to fly back to the U.K. following the Def Con security conference in Las Vegas. Prosecutors charged Hutchins with his involvement with creating the Kronos banking malware, dating back to 2014. He was later freed on bail.

A plea agreement was filed with the Eastern District of Wisconsin, where the case was being heard on Friday. His trial was set to begin later this year.

Hutchins agreed to plead guilty to distributing Kronos, a trojan that can be used to steal passwords and credentials from banking websites. In recent years, the trojan has continued to spread. He also agreed to plead guilty to a second count of conspiracy.

Hutchins faces up to 10 years in prison. Prosecutors have dropped the remaining charges.

In a brief statement on his website, Hutchins said: “I regret these actions and accept full responsibility for my mistakes.”

“Having grown up, I’ve since been using the same skills that I misused several years ago for constructive purposes,” he said. “I will continue to devote my time to keeping people safe from malware attacks.”

His attorney Marcia Hofmann did not immediately return a request for comment.

Hutchins rose to prominence after he stopped the spread of the WannaCry ransomware attack in May 2017, months before his arrest. The attack used powerful hacking tools developed by the National Security Agency, which were later leaked, to backdoor thousands of Windows computers and install ransomware. The attack was later attributed to hackers backed by North Korea, knocking U.K. hospitals offline and crippling major companies around the world.

By registering a domain name found in the malware’s code, Hutchins stemmed the spread of the infection. He was hailed a hero for stopping the attack.

Prior to his release and after, Hutchins gained further praise and respect from the security community for his contributions to the malware-reversing field, and demonstrating his findings so others can learn from his findings.

Justice Department spokesperson Nicole Navas declined to comment.