In a forceful, profanity-laced speech, he accused Crozier of "betrayal," called him "too naive or too stupid" and suggested the sailors' love for him was misplaced.
Hours later, back in Washington, Modly issued an apology, but President Donald Trump publicly questioned Crozier's treatment and said he would get directly involved.
Modly "resigned of his own accord, putting the Navy and the sailors above self so that the USS Theodore Roosevelt, and the Navy as an institution, can move forward," Esper said in a statement. Esper said Modly's replacement as acting Navy secretary will be current Army Undersecretary Jim McPherson, a retired admiral.
Modly was the second navy chief to depart in just over four months.
In November, Esper fired Navy secretary Richard Spencer after he pushed back against Trump's protection of Navy SEAL Edward Gallagher, who had been charged with war crimes and convicted of lesser charges.
Gallagher was demoted and was to lose his identity as a member of the elite SEAL corps until Trump stepped in, drawing accusations that he was undermining the authority of the military leadership by condoning Gallagher's behavior. But that case, according to some analysts, put pressure on Trump to also give some support to Crozier, whose career was spotless.
The navy veteran had written a letter to his superiors in late March complaining of an uncontrolled Covid-19 outbreak among the Roosevelt's 4,800 crew, and called on the Pentagon to allow him to vacate the nuclear-powered ship and sterilize it.
"The spread of the disease is ongoing and accelerating," Crozier wrote. "We are not at war. Sailors do not need to die." The letter was published by the San Francisco Chronicle, a leak Esper and Modly insinuated was deliberate and violated the Pentagon's chain of command.
Crozier "demonstrated extremely poor judgment in the middle of a crisis" in his handling of the letter, Modly said. "It misrepresented the facts of what was going on the ship" and created "a little bit of panic" that was unnecessary, he said.
Still, Roosevelt has been docked for 11 days in Guam so the crew, with well over 200 confirmed coronavirus
cases, can be tested and the vessel can be sanitised.
Trump said Tuesday that he was not involved in Modly's departure, but said Crozier was wrong for writing the letter and that Modly "probably shouldn't have said quite what he said." "I didn't speak to him but he did that, I think, just to end that problem," he said of Modly's resignation.