WASHINGTON — The captain had reached a breaking point.

The aircraft carrier he commanded, the Theodore Roosevelt, was docked in Guam as the coronavirus raced unchecked through its narrow corridors. The warship’s doctors estimated that more than 50 crew members would die, but Capt. Brett E. Crozier’s superiors were balking at what they considered his drastic request to evacuate nearly the entire ship.

Captain Crozier was haunted by the Diamond Princess, a cruise ship of 2,600 passengers in individual cabins where the virus had killed eight people and infected more than 700. The situation on his ship had the potential to be far worse: nearly 5,000 sailors crammed in shared berths, sometimes stacked three high. Eight of his sailors with severe Covid-19 symptoms had already been evacuated to the Navy’s hospital in Guam.

On March 30, after four days of rebuffs from his superiors, Captain Crozier sat down to compose an email. “Sailors don’t need to die,” he wrote to 20 other people, all Navy personnel in the Pacific, asking for help. A Naval Academy graduate with nearly 30 years of military service, the captain knew the email would most likely end his career, his friends said in interviews. The military prizes its chain of command, and the appropriate course would have been for the captain to continue to push his superiors for action.

He hit “send” anyway.

Three weeks later, the fired captain is battling the coronavirus himself, 584 other crew members have tested positive and the acting Navy secretary has resigned. The secretary, Thomas B. Modly, removed the captain because he thought that was what President Trump wanted, officials said. Mr. Modly, the officials said, was keenly aware that his predecessor in the job had been fired after tangling with Mr. Trump. But in trying to please the president, Mr. Modly miscalculated and destroyed his own career.