President Trump's top immigration adviser Stephen Miller reportedly played a central role in the series of events that led to the resignation of Homeland Security Secretary Kirstjen Nielsen on Sunday.

In a pair of tweets, Trump confirmed Nielsen's resignation after they met at the White House in the early evening. In doing so, Trump announced Kevin McAleenan, the commissioner of U.S. Customs and Border Protection, will become acting DHS secretary.

Although Nielsen wrote in her resignation that she "determined that it is the right time for me to step aside," reports indicate it was Miller who orchestrated her exit.

A senior U.S. official told CBS News that Nielsen's resignation was part of a larger effort by Miller to overhaul DHS. This comes after the New York Times reports Trump and Miller would often complain in private about Nielsen, pinning on her the blame for a surge in migrants arriving to the U.S. and a lack of a solution to secure the border with Mexico.

The White House did not immediately return a request for comment.

[Related: Ann Coulter celebrates Kirstjen Nielsen's resignation: 'Hallelujah!']

The announcement of Nielsen's departure follows top officials at the Department of Homeland Security, including Nielsen, being caught off guard by the White House’s sudden move Thursday night to pull the nomination of Ronald Vitiello to lead Immigration and Customs Enforcement.

This unanticipated maneuver, according to the Washington Post, was due in large part to Miller's rise in influence. Miller, along with ICE union head Chris Crane, had complained about Vitiello. Trump told reporters Friday he wanted somebody "tougher" for the top immigration enforcement role.

Miller, who joined Trump’s 2016 presidential campaign from the staff of then-Sen. Jeff Sessions, R-Ala., and remains the one of the last top aides from those days to remain in the White House, has a hard-line view of immigration in line with Trump's tough rhetoric during the campaign and his administration.

A recently released tell-all book about the West Wing said Miller spoke harshly about refugees coming to the U.S. In Team of Vipers, former White House communications aide Cliff Sims quotes Miller as saying, “I would be happy if not a single refugee foot ever again touched American soil.”

Miller also defended Trump's controversial emergency declaration to divert funds for a border wall along the U.S.-Mexico border after Congress declined to appropriate the billions of dollars Trump sought for the project.

Despite the hard feelings that reportedly ran rampant behind the scenes, Trump was gracious in announcing Nielsen's departure Sunday.

"Secretary of Homeland Security Kirstjen Nielsen will be leaving her position, and I would like to thank her for her service," he tweeted.

In her resignation letter, Nielsen wished her successor good luck in dealing with border security. “I hope that the next Secretary will have the support of Congress and the courts in fixing the laws which have impeded our ability to fully secure America’s borders and which have contributed to discord in our nation’s discourse," she said.