Dunford is scheduled to retire in October 2019 at the end of his second two-year term.
"I am thankful to both of these incredible men for their service to our Country!" Trump said on Twitter in making the announcement.
"Mark is a great gentleman, great soldier. I look forward to that," Trump then told reporters before heading to the annual Army-Navy football game in Philadelphia.
But in choosing the 60-year-old Milley, a graduate of Princeton University known for his combat command experience, Trump went against the wishes of Mattis, who reportedly favoured Air Force General David Goldfein.
That choice would have been in keeping with a tradition of rotating the post among the services. Dunford is a Marine Corps general.
Dunford quickly offered his congratulations to Milley. "He has served with General Milley in peacetime and in combat and has the highest regard for his leadership," said Dunford's spokesman, Colonel Patrick Ryder.
Milley must be confirmed by the US Senate. He would take the position for a four-year term, after a new law was passed last year doubling the term length to better ensure continuity. Trump said the transition date was "to be determined," in a sign that Dunford might go sooner rather than later, but Ryder noted: "All indications are that General Dunford will serve his full term."
Trump announced his picks for a new attorney general and a new UN ambassador on Friday. On Saturday, he also announced that chief of staff John Kelly, a retired Marine Corps general, would leave by year's end.
After meeting with both Milley and Goldfein, it seems that Trump preferred the army general, who was more outgoing than the cerebral Air Force chief, and laced his discussions with humour and historical references.
The Pentagon's reaction to the announcement was somewhat frosty. "We are aware of the president's nomination and share his confidence for General Mark Milley," Pentagon spokesman, Lieutenant Colonel Mike Andrews, said in a brief statement.
"The Department of Defense remains fully focused on defending our nation." Mattis was once a favorite of Trump, but the two men have had increasing difficulties in recent months.
They haven't seen eye to eye over the Iran nuclear deal, which Trump withdrew from over Mattis' objections; over the creation of a Space Force, which Mattis did not want; and over the crisis at the US-Mexico border, and the deployment of troops there.
Mattis and Dunford are expected to attend the Army-Navy game on Saturday along with Trump. The game features cadets from the Naval Academy against their counterparts from the US Military Academy and is often attended by the president.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)