WUHAN, China — He was the doctor who tried to sound a warning that a troubling cluster of viral infections in a Chinese province could grow out of control — and was then summoned for a middle-of-the-night reprimand over his candor.

On Friday, the doctor, Li Wenliang, died after contracting the very illness he had told medical school classmates about in an online chat room, the coronavirus. He joined the more than 600 other Chinese who have died in an outbreak that has now spread across the globe.

Dr. Li “had the misfortune to be infected during the fight against the novel coronavirus pneumonia epidemic, and all-out efforts to save him failed,” the Wuhan City Central Hospital said on Weibo, the Chinese social media service. “We express our deep regret and condolences.”

Even before his death, Dr. Li had become a hero to many Chinese after word of his treatment at the hands of the authorities emerged. In early January, he was called in by both medical officials and the police, and forced to sign a statement denouncing his warning as an unfounded and illegal rumor.