It was the Democrats’ debate do-over. And on Tuesday night, Philadelphia gave Democrats what Atlanta did not — a presidential debate they could feel good about.

It had been less than three months since that fateful night in Atlanta, when President Joe Biden struggled so visibly — and looked so weak and infirm in his debate against former President Donald Trump — that his own party loyalists mounted an effort to push him off the presidential ticket.

That night it was Trump, not Biden, who seemed prepared and disciplined, sticking to the script as his advisers had hoped would. Along with focusing on the economy and immigration, Trump ridiculed Biden for his meandering answers.

“I don’t know what he just said,” Trump said after an especially incoherent moment from Biden. “I don’t think he knows what he just said.”

The debate, and the presidential contest, seemed over in that moment.

But 10 weeks and a new Democratic nominee later, it was Vice President Kamala Harris on Tuesday night in Pennsylvania who took a page out of the Trump debate playbook — attacking, insulting and ultimately making Trump the one who sounded incoherent.

The debate began as expected, with a back-and-forth about the economy and the usual mix of talk about tariffs and taxes and the inflation rate following COVID. When Trump accused Harris of overseeing “inflation like very few people have ever seen before,” she made it clear that she had come to the night prepared to respond to what Trump served up.

“What we have done is clean up Donald Trump’s mess,” she said, blaming Trump for the economy she and Biden inherited.

When the topic turned to immigration, another clear strong suit for Trump, Harris brushed past the clear deficiencies in the Biden record at the border and segued to the one subject the former president is known to hold most dear — the crowd sizes at his rallies.

“What you will also notice is that people start leaving his rallies early out of boredom and exhaustion,” she said. “The one thing you will not hear him talk about is you.”

From that moment on, Trump seemed off his game. Instead of returning to the topics where he holds an advantage, as he did repeatedly in Atlanta, he chased down every Harris insult, often with a pile of nonsense.

“People don’t leave my rallies,” he said when ABC’s David Muir asked him about the Senate immigration bill that Trump publicly spiked. “We have the biggest rallies, the most incredible rallies in the history of politics.”

After the rallies, he moved onto the dogs.

“In Springfield, they’re eating the dogs. The people that came in, they’re eating the cats. They’re eating — they’re eating the pets of the people that live there. And this is what’s happening in our country. And it’s a shame.”

Are you confused yet? Trump seemed to be.

When moderator David Muir pointed out that the city manager of Springfield, Ohio, said the story circulating in the right-wing media about Haitian immigrants abducting pets was not accurate, the former president dug in: “Well, I’ve seen people on television. … The people on television say. ‘My dog was taken and used for food.’”

After the dogs, it was the dictators.

When the topics turned to the Middle East, Afghanistan, the military or veterans, Harris used her time again and again to deliver a single message to Trump — behind your back, nobody respects you.

For a man who prides himself on his image of strength, the vice president’s strategy was to mock and belittle him — just as he did to so many of his past debate foes. That it was a woman doing the deed to Trump seemed to especially bother him.

Talking about foreign policy, Trump claimed that Harris “hates Israel and, in her own way, hates the Arab countries.”

She shot back, “Dictators and autocrats are rooting for you to be president again because, they’re so clear they can manipulate you with flattery and favors.” World leaders, she said, “are laughing at Donald Trump.”

On three occasions, she said American military leaders told her that Trump is “a disgrace.”

“That is why we understand that we have to have a president who is not consistently weak and wrong on national security,” she said.

“Weak.” “Wrong.” “A disgrace.” A laughingstock. Harris used Trump’s own insults against him, and it worked.

When the vice president wasn’t getting him off his game, Trump did it himself. After weeks of trying to chart a more moderate stance on abortion, Trump said he did a great service to the American people by appointing Supreme Court justices to overturn Roe v. Wade: “I did a great service in doing it. It took courage in doing it.”

And to the groans of Republican leaders in Georgia, Trump also insisted that he won the 2020 election, including in Georgia, which he did not.

“There is so much proof. All you have to do is look at it, and they should have sent it back to the legislatures for approval,” Trump said. “I’ll show you Georgia and I’ll show you Wisconsin and I’ll show you Pennsylvania and I’ll show you — we have so many facts and statistics.”

It’s not clear how many votes a debate like Tuesday’s would move in one direction or another. But look no further than the debate in Atlanta to remember that a bad performance can have devastating consequences that last.

By the time the debate was over, both the Harris and Trump campaigns said they want another debate before November. The Harris team clearly thinks she won the debate and would win another, while the Trump camp could use a do-over of their own.

As erratic as Trump is, he just might win the next one, as long as he leaves the dogs, the dictators and the election denials out of it.