Miller will be regarded as the Acting Secretary of Defense, effective immediately, Trump said in a Twitter message.
Esper, who opposed use of active duty troops to suppress domestic civil unrest during the summer, has seen his relationship with Trump deteriorate, was expected to resign following the election.
NBC News reported last week, citing Defense Department officials, that Esper had prepared a letter of resignation, however the Pentagon denied at the time that he was fired or had resigned.
With the apparent victory of former Vice President Joe Biden in the 2020 presidential election, others in Washington stressed that Esper should remain in the position, in part to assure citizens that the U.S. military will not be involved in a transition of power.
Some legislators and defense establishment figures urged Esper to stay on as secretary during the transition prior to the inauguration.
"For the good of our country and the brave men and women in uniform, I hope [Esper] will continue to serve for the remainder of the Trump presidency," Sen. Tim Kaine, D-Va., said in a statement.
Esper's firing raises questions about the military chain of command at a time when Trump seeks to demonstrate his hold on his executive powers, despite the outcome of the election, officials and experts have said.
"This is a matter of national security," Arnold Punaro, retired Marine Corps major general and former staff director for the Senate Armed Services Committee, told Politico prior to Monday's announcement.
"During the next 76 days [prior to the Jan. 20, 2021, inauguration], our allies and adversaries should understand that President Trump retains full powers as commander in chief and the chain of command is intact from him to Secretary Esper to the warfighting commanders," Punaro said.
Miller was sworn in as director of the National Counterterrorism Center in August after serving as a policy official at the National Security Council.