WASHINGTON — It was a setting tailor-made for President Donald Trump to launch into a partisan address, with a VIP crowd in front of him that included Republican donors and a display of military armor and aircraft he had personally ordered for a “Salute to America” on the National Mall.

But during the Fourth of July extravaganza, the president diverged from his typical self-aggrandizing speaking style and instead turned his praise toward the military and ordinary Americans who have contributed to the country’s advancement.

“As we gather this evening in the joy of freedom, we remember that all share a truly extraordinary heritage,” Trump said from the steps of the Lincoln Memorial, where rain had drenched and scattered some of those gathered. “Together, we are part of one of the greatest stories ever told — the story of America. It is the epic tale of a great nation whose people have risked everything for what they know is right and what they know is true.”

The event was clouded in controversy in part because of the fear that the president was inserting himself into a typically nonpolitical event and planning to use a taxpayer-funded celebration of military power to bolster his own political prospects.

But Trump largely steered clear of rank partisanship and instead spoke of the history of America’s founding while reveling in the displays of military might from the U.S. armed forces.

He introduced the five branches of the U.S. military as aircraft from the Army, Navy, Marines, Coast Guard and Air Force flew overhead.

Abrams tanks and Bradley Fighting Vehicles were also stationed on the National Mall, as a B-2 bomber and F-22 fighter jets flew overhead.

For months, the president had taken special interest in the event, receiving regular briefings and requesting specific features, from tanks to Air Force One.

“July Fourth is being turned into a big campaign event,” Julian Zelizer, a professor of history and public affairs at Princeton, said Thursday before Trump’s speech on Twitter.

Before the address, heavy rain drenched much of Washington, leaving many attendees on the National Mall soaked or scrambling to find shelter.

During Trump’s opening remarks, he referred to several people in the crowd — including a NASA legend, a nun, a hurricane volunteer, a 1960s civil rights activist and others — telling stories of individual heroism.

“Americans love our freedom and no one will ever take it away from us,” he said. “For Americans, nothing is impossible.”

The president name-checked the women’s suffrage movement and the civil rights movement, referring to several prominent American historical figures.

“In 1963, Rev. Dr. Martin Luther King Jr. stood here on these very steps and called on our nation to live our the true meaning of its creed and let freedom ring for every citizen all across our land,” he said. “America’s fearless resolve has inspired heroes who defined our national character from George Washington, John Adams and Betsy Ross to ... the great Frederick Douglass, Harriet Tubman, Amelia Earhart, Douglas MacArthur, Dwight Eisenhower, Jackie Robinson and of course, John Glenn.”

The president’s reference to Betsy Ross was the closest he came to offering political red meat to his base. Ross, who sewed the first American flag, became the subject of controversy this week after Nike halted the sale and production of sneakers sporting the Betsy Ross flag. Former NFL quarterback Colin Kaepernick — a Nike spokesman — told the company the design was offensive, The Wall Street Journal reported.

Conservatives have rallied to Ross’ defense in recent days.

Trump spoke to a crowd that was divided between a VIP section for supporters and donors near the stage and an area for the general public held at bay by chain link fences far away. All together, thousands of people gathered to witness flyovers by military aircraft, musical performances and a 35-minute fireworks show.

Trump administration officials have refused to say how much taxpayers will have to pay for the expanded celebration on the National Mall this year. The Washington Post reported Tuesday that the National Park Service is diverting almost $2.5 million in fees to cover some of the costs associated with the event.

Those fees represent a fraction of the extra costs the government is incurring for the event, and the spending is drawing scrutiny from congressional investigators.

Democrats have accused the president of using the Fourth of July celebration for political purposes, and some have publicly decried the display of military might as a reflection of Trump’s authoritarian impulses.