WASHINGTON -- Acting Navy Secretary Thomas Modly resigned Tuesday, according to two officials, just hours after he had publicly apologized for a profanity-laced upbraiding of the officer he fired as captain of the coronavirus-stricken USS Theodore Roosevelt.

The officials spoke on condition of anonymity in order to discuss the matter before an official announcement.

Modly's designated replacement will be James McPherson, a Navy veteran who is currently serving undersecretary of the Army. He was confirmed in that position by the Senate last month. Prior to that he was the Army's general counsel.

Modly had created a combustible controversy by firing the Roosevelt's skipper, Capt. Brett E. Crozier, last week, saying Crozier had shown "extremely poor judgment" in widely distributing by email a letter calling for urgent help with the COVID-19 outbreak aboard his ship.

Modly then flew to the ship, at port in Guam, and delivered a speech to the crew Sunday in which he lambasted Crozier, saying he was either "too naive or too stupid" to be in charge of an aircraft carrier.

On Monday night, at Esper's insistence, Modly issued a public apology, but by then the calls among Democrats in Congress for his resignation were mounting. On Tuesday morning, House Speaker Nancy Pelosi said Modly must go.

"Sadly, Acting Secretary Modly's actions and words demonstrate his failure to prioritize the force protection of our troops," Pelosi, D-Calif., said in a written statement. "He showed a serious lack of the sound judgment and strong leadership needed during this time. Acting Secretary Modly must be removed from his position or resign."

At least 173 sailors aboard the ship had tested positive for the coronavirus as of Monday. About 2,000 of the 4,865 crew members had been taken off the ship to be tested.

The episode, which began when the Roosevelt reported its first COVID-19 case among the crew on March 22, two weeks after making a port visit in Vietnam, is one of the more extraordinary dramas in recent U.S. military history. In addition to the health threat posed to the crew of more than 4,800 sailors, the outbreak has sidelined the warship indefinitely and created conflict at the highest levels of the Pentagon.

Defense Secretary Mark Esper had publicly expressed his support for Modly's decision to fire Crozier, but after Modly's speech about the ship, Esper grew unsettled. Just hours after Modly issued a statement Monday defending his words, Esper compelled Modly to reverse course and issue a public apology.

"I want to apologize for any confusion this choice of words may have caused," he wrote, referring to his speech aboard the Roosevelt. "I also want to apologize directly to Captain Crozier, his family, and the entire crew of the Theodore Roosevelt for any pain my remarks may have caused."

Esper's staff had told Modly he must apologize, according to a person familiar with the matter who spoke on the condition of anonymity to discuss a private conversation.

Trump told reporters at the White House on Monday that he might get involved, agreeing that Modly's criticism of Crozier was "a rough statement." He said Crozier made a mistake when he sent a memo to several people laying out his concerns about the crew and the virus. In the memo, which was leaked to the media, Crozier said: "We are not at war. Sailors do not need to die."

Trump said Crozier had a good career prior to this incident, adding, "I don't want to destroy somebody for having a bad day."

Modly, in his apology, reframed his earlier remarks that Crozier was "too naive or too stupid" to command. Instead, he said he believes Crozier is "smart and passionate."

"I believe, precisely because he is not naive and stupid, that he sent his alarming email with the intention of getting it into the public domain in an effort to draw public attention to the situation on his ship," Modly wrote.

Aboard the ship, Modly had urged the crew to stop complaining.

"It is the mission of the ship that matters," he said. "You all know this, but in my view your Captain lost sight of this and he compromised critical information about your status intentionally to draw greater attention to your situation."

Modly, a 1983 Naval Academy graduate, became the acting Navy secretary last November after Richard Spencer was ousted from the position. Trump last month nominated retired Rear Adm. Kenneth Braithwaite, the current ambassador to Norway, to be the next Navy secretary.

In his remarks aboard the Roosevelt, Modly raised issues likely to please Trump. He accused the news media, for example, of manipulating a political agenda to divide the country and embarrass the Navy. He said China "was not forthcoming" about the coronavirus when it began spreading there months ago, echoing Trump's oft-repeated statement that China could have done more to prevent a pandemic.

And Modly invoked the name of Trump's chief Democratic challenger, Joe Biden, noting that the former vice president had said Modly's decision to fire Crozier was almost criminal. "I assure you it was not," Modly said.

Modly said Crozier should have known his letter voicing urgent concerns about the virus aboard his ship would leak to the media. He said if Crozier didn't think this would be the result, he was "too naive or too stupid to be a commanding officer of a ship like this."

He also accused Crozier of betraying his duty as an officer. "And I can tell you one other thing, because he did that he put it in the public's forum and it's now become a big controversy in Washington D.C., and across the country," Modly said.

After an unofficial transcript of Modly's remarks and an audio recording circulated widely on the internet Monday, Rep. Elaine Luria, a Virginia Democrat and Navy veteran, called for Modly to be fired.

Luria said Modly's comments show he is "in no way fit" to lead the Navy. Luria's district includes Naval Station Norfolk, the world's largest naval base.