President Trump's pick for director of U.S. Immigration and Customs Enforcement is going to be working with the same official who fired him as head of the Border Patrol in 2017 — and internal emails obtained by Axios' Alayna Treene reveal just how bitter Morgan's exit was.

Why it matters: The emails — dated Jan. 24 and 25, 2017 — show the depth of Morgan's anger and disappointment with the Trump administration for forcing him out of the role. But they also show how far Morgan has come to get back into Trump's good graces, after talking up Trump's immigration policies on television and endorsing his proposed border wall.

" The fact they are pushing for me to leave immediately is heartless and void of any decency and compassion," Mark Morgan wrote to Kevin McAleenan, the former acting commissioner of Customs and Border Protection who is now Trump's acting secretary of the Department of Homeland Security. "This is just wrong."

for me to leave immediately is heartless and void of any decency and compassion," Mark Morgan wrote to Kevin McAleenan, the former acting commissioner of Customs and Border Protection who is now Trump's acting secretary of the Department of Homeland Security. "This is just wrong." "I am being removed in the name of politics — and politics at its worst. … I will not have them believe I willingly left under these circumstances," Morgan wrote in one of the emails to McAleenan.

— and politics at its worst. … I will not have them believe I willingly left under these circumstances," Morgan wrote in one of the emails to McAleenan. In a separate email, he wrote: "This is wrong on many levels. I have several questions but I need to process through a bit more."

The reason for Morgan's removal isn't clear from the emails, and no official reason was given at the time of his resignation. But the National Border Patrol Council — a union representing 16,500 border patrol agents that endorsed Trump in 2016 — opposed him at the time because of what they described as his lack of experience.

A source familiar said Morgan's firing was Trump's doing, because the union's president, Brandon Judd, privately told Trump to get rid of him. (Judd has had an outsized influence over Trump's running of the Department of Homeland Security in relation to the relatively modest size of his union.)

was Trump's doing, because the union's president, Brandon Judd, privately told Trump to get rid of him. (Judd has had an outsized influence over Trump's running of the Department of Homeland Security in relation to the relatively modest size of his union.) Oddly, Judd seems to have reversed himself and is now praising Morgan's experience — at least publicly. After Trump announced he wanted Morgan to run ICE, Judd told Politico that Morgan would be a good fit to run the enforcement agency, given his investigative background at the FBI.

Context: Morgan, a career FBI official, was selected to run the U.S. Border Patrol in the final months of the Obama administration. He was the first chief in the 93-year history of the agency who had never worked as a border patrol agent, per the New York Times.

His appointment drew backlash from the Border Patrol union, which argued that an insider should have been given the position. It called Morgan "a disgrace" to the agency in a Nov. 2016 Breitbart op-ed.

However, in the two years since his firing, Morgan has praised Trump's hardline border policies in television interviews and congressional testimony — calling for more aggressive executive action on immigration and criticizing longstanding U.S. law and nationwide injunctions.

Those appearances seem to have paid off, with Trump reportedly calling Morgan after seeing him on TV to applaud his performance, per the Washington Post.

Morgan and McAleenan also seem to have warmed to each other again. In yet another twist in their relationship, McAleenan threatened to quit after White House senior adviser Stephen Miller tried to force McAleenan to make Morgan the head of CBP instead of ICE director, the Washington Post reported Friday.

Following former DHS Secretary Kirstjen Nielsen's departure in April, Morgan told Fox News that McAleenan should be the next DHS secretary, calling him "extremely intelligent."

Kirstjen Nielsen's departure in April, Morgan told Fox News that McAleenan should be the next DHS secretary, calling him "extremely intelligent." And McAleenan praised Trump's decision to select Morgan for ICE director, saying Morgan's "record of service is needed to address the crisis at the border. ... The depth of his experience will be an asset to the Department and I look forward to working with him."

Morgan told Axios in a statement: Serving the men and women at Immigration and Customs Enforcement is a privilege. ... I look forward to rejoining the DHS workforce and working hand-in-hand with our law enforcement partners and the interagency community to enforce our nation’s immigration laws and end the humanitarian and security crisis at our southern border.