The firing of Esper, who had clashed with Trump over his suggestion of using military personnel to quash civic unrest, comes a week after the US presidential election.
He said his visit is part of a broader US initiative to strengthen older alliances and develop new ones against Russian and Chinese efforts to build their own global power networks.
In a repositioning that could start within weeks, the Pentagon will be sending home about 6,400 of its military personnel in Germany, and move nearly 5,600 to other NATO countries.