LONDON — A British security researcher who was hailed as a hero for helping to stop a global “ransomware” cyberattack in 2017 has pleaded guilty to charges in the United States of writing malicious software in a separate case.

The researcher, Marcus Hutchins, was arrested at the Las Vegas airport in 2017, when he was on his way back to Britain from a conference.

“As you may be aware, I’ve pleaded guilty to two charges related to writing malware in the years prior to my career in security,” Mr. Hutchins, known online as MalwareTech, said in a statement on his website on Friday. “I regret these actions and accept full responsibility for my mistakes.”

Mr. Hutchins faces up to five years in prison and $250,000 in fines for each of the charges, according to United States court documents.