The vote was 89-1 for Milley, now the Army Chief of Staff, to replace Marine General Joseph Dunford.
Democratic Senator Jeff Merkley was the only dissenting vote.
Milley, 61, served in Iraq, Afghanistan and in other countries before becoming the Army’s top officer in August 2015.
His appointment follows several other Pentagon leadership changes during Trump’s tumultuous presidency.
Earlier this week, the Senate confirmed Army Secretary Mark Esper, a military veteran and former defense industry lobbyist, as Trump’s second secretary of defense, ending seven months – the longest period ever – that the Pentagon had been without a permanent top official.
There were three acting secretaries of defense in the interim, including Esper and Patrick Shanahan, a former Boeing Co executive who withdrew from consideration as defense secretary last month after reports emerged of domestic violence in his family.
Also this week, Trump’s nominee to be vice chairman of the Joint Chiefs, Air Force General John Hyten, has been facing questions about whether he would be confirmed because he is being investigated for an alleged sexual assault.
At his confirmation hearing this month, Milley told the Senate Armed Services Committee he would not be “intimidated into making stupid decisions” and would give his best advice to Trump regardless of pressure.
U.S. officials have said Milley has a good rapport with Trump, who announced his plan to nominate Milley last year, months sooner than expected.
Milley is due to assume his new post on Oct. 1, the end of Dunford’s term.
Reporting by Patricia Zengerle; Editing by Tom Brown