Retired General John Kelly. REUTERS/Joshua Roberts

Retired Marine Gen. John Kelly, President Donald Trump's new chief of staff, nearly resigned over the way Trump fired former FBI director James Comey in May, sources told CNN on Monday.

"John was angry and hurt by what he saw and the way [Comey] was treated," one source said.

Kelly was serving as Trump's homeland security secretary at the time Comey was fired, and the two men reportedly had a professional relationship and a "deep mutual respect" for each other, according to CNN.

Comey was fired on May 9 and became aware of Trump's decision when he saw it break on cable news, while he was addressing FBI employees in Los Angeles. When he first saw the headlines, Comey laughed and thought it was a prank, The New York Times reported.

After getting confirmation that he was, in fact, fired, Comey left Los Angeles for Washington and took a phone call from Kelly on the way, CNN reported. When he learned that Kelly may resign over the events that had transpired, Comey urged him not to.

Kelly recently accepted a position as Trump's chief of staff, replacing Reince Priebus, who was ousted on Friday amid brewing tensions with White House communications director Anthony Scaramucci, who was ousted on Monday.

Scaramucci's ouster followed an explosive interview he gave to The New Yorker, during which he called Priebus "a paranoid schizophrenic — a paranoiac" and made vulgar comments about White House chief strategist Steve Bannon.

Kelly was reportedly the one who requested that Scaramucci be removed as communications director, in an effort to assert that he was in charge, according to the Times.