Supporters welcomed his tribute to the US military while protesters attacked him for putting himself centre stage on a holiday devoted to unity.
Mr Trump called on Americans to “stay true to our cause” in a Fourth of July celebration which adhered to patriotic themes and hailed an eclectic mix of history’s heroes, from the armed forces, space, civil rights and other endeavours of American life.
He stuck largely to his script, avoiding diversions into his agenda or re-election campaign.
But in one exception, he vowed: “Very soon, we will plant the American flag on Mars” – a distant goal not likely to be achieved until late in the 2020s if even then.
A late afternoon downpour drenched Washington DC’s Independence Day crowds, but Mr Trump’s speech unfolded in occasional rain, and the warplanes and presidential aircraft he had summoned conducted their flyovers as planned, capped by the Navy Blue Angels aerobatics team.
By adding his own, one-hour Salute to America production to capital festivities that typically draw hundreds of thousands anyway, Mr Trump became the first president in nearly seven decades to address a crowd at the National Mall on Independence Day.
Protesters objecting to what they saw as his co-opting of the holiday inflated a balloon depicting Mr Trump as an angry, nappy-clad baby.
Not since 1951, when US president Harry Truman spoke before a large gathering on the Washington Monument grounds to mark the 175th anniversary of the signing of the Declaration of Independence, has a commander in chief made an Independence Day speech to a sizeable crowd on the Mall.
Pete Buttigieg, one of the Democrats running for president, said: “this business of diverting money and military assets to use them as a kind of prop, to prop up a presidential ego, is not reflecting well on our country”.
Washington has held an Independence Day celebration for decades, featuring a parade along Constitution Avenue, a concert on the Capitol lawn with music by the National Symphony Orchestra and fireworks beginning at dusk near the Washington Monument.
Mr Trump altered the lineup by adding his speech, moving the fireworks closer to the Lincoln Memorial and summoning the tanks and warplanes.