Former President Donald J. Trump’s first television ad attacking his new rival, Vice President Kamala Harris, splices together footage of her dancing and images of migrants crossing the border as the ad accuses her of being a failed “border czar.”

The 30-second ad aims to hold Ms. Harris responsible for millions of border crossings and a quarter-million deaths from fentanyl, which the ad says occurred “on Harris’s watch.” It closes with a new Trump tagline for Ms. Harris: “Failed. Weak. Dangerously Liberal.”

The words flash on the screen as she dances, footage from an event celebrating the 50th anniversary of hip-hop.

It is the Trump campaign’s first major television ad purchase of the election since Ms. Harris became the de facto Democratic nominee. The campaign began making a two-week ad reservation on Monday, buying time in the six top battlegrounds.

The spending by state, according to data from AdImpact, the ad-tracking service, is $2.7 million in Pennsylvania, $2.3 million in Georgia, $2.3 million in Michigan, $1.9 million in Arizona, $1.8 million in Nevada and $1.3 million in Wisconsin.

The ad also makes use of an interview Ms. Harris did with NBC’s Lester Holt in 2021 when, as she was facing pressure from Republicans to visit the border, she said that she did not understand why her presence would be so important. “I haven’t been to Europe,” Ms. Harris said. “I mean, I don’t understand the point you’re making.”