Republican Party elected officials in contested races around the country have been grappling with a basic but profound issue all year — how do you stand up for the GOP and conservative principles and against Hillary Clinton without getting sucked into defending every crazy, offensive, or weird thing Donald Trump has said? It can be a tough line to walk, as New Hampshire Sen. Kelly Ayotte learned this week.

Debating Tim Kaine Tuesday night, Mike Pence taught a master class in how it’s done. Every time Kaine attacked, Pence parried and deftly shifted the conversation to something else entirely.

Pence has amazing discipline in not defending @realDonaldTrump #VPDebate — Ben White (@morningmoneyben) October 5, 2016

When Kaine demanded that Pence defend Trump’s secrecy on his taxes, Pence ducked and talked about how low taxes are good for economic growth. When Kaine offered an extended list of Trump insults that he said he couldn’t believe Pence would defend, Pence didn’t defend them — he pivoted to complaining about Clinton and the “basket of deplorables.” Pence was tight, disciplined, and focused on his talking points. He never took the bait, never let himself get dragged into unfavorable terrain, and simply ignored subjects he didn’t want to discuss.

It was a genuinely bravura performance, one that a passel of GOP senators and Congress members running in tough races ought to study. The problem is Trump is at the top of the ticket.

Pence simply couldn’t defend Trump

The crowning moment of the debate came at around 9:45 pm, when Kaine launched into a devastating foreign policy attack on Donald Trump:

Donald Trump cannot start a Twitter war with Miss Universe without shooting himself in the foot. He does not have a plan. He said "I have a secret plan," and then he said, "I know more than all the generals about ISIL," and finally he said, "I am going to fire all the generals." He does not have a plan. He trash talks the military, John McCain is no hero, the generals need to be fired, I know more than them. NATO is obsolete. And third, he loves dictators. He has a personal Mount Rushmore of Vladimir Putin, Kim Jong Un, and Saddam Hussein. He believes — Donald Trump believes that the world will be safer if more nations have nuclear weapons. He said Saudi Arabia should get them, Japan should get them, and Korea should get them. When he was confronted with this, he said, "Go ahead, folks, enjoy yourselves." I would like Gov. Pence to say what is so enjoyable or comical about nuclear war.

Pence simply could not and would not defend any of this. Instead, he tried to deflect, saying, “That had a lot of creative lines in it.”

Kaine pressed again: “See if you can defend any of it?”

Pence pivoted into a generic conservative attack on Obama’s foreign policy:

I want to give this president credit for bringing Osama bin Laden to justice, but the truth is, Osama bin Laden led al-Qaeda. The primary threat today is ISIS. Because Hillary Clinton failed to renegotiate a forces agreement that would have allowed some American combat troops to remain in Iraq and secure the hard-fought gains that the American soldier has won, ISIS was able to be literally conjured up out of the desert, and it has overrun vast areas. My heart breaks for the likes of Corporal Lebowski. He fought hard, through some of the most difficult days of Operation Iraqi Freedom, and paid the ultimate sacrifice to secure the nation. That nation was secured in 2009. Because Hillary Clinton and Barack Obama failed to provide a status of forces agreement and leave sufficient forces, we are back at war. We are back at war in Iraq. [...]

It was a deftly executed move. And while the substance of the critique is somewhat unfair, it’s not crazy. The Obama administration’s attempted withdrawal from Iraq pretty clearly has not worked out nearly as well as it hoped.

But Pence utterly failed to take up Kaine’s challenge to defend Trump’s affection for Putin, dislike of NATO, or willingness to entertain nuclear proliferation. Pence simply shrugged off the entire reality of Trump’s 2016 campaign and slammed Obama, Clinton, and Kaine as soft on Russia — a smooth extension of the foreign policy messages of John McCain in 2008 and Mitt Romney in 2012.

Kaine is running for VP; Pence is running for 2020

If Kaine and Pence had been debating for an Ohio Senate seat, any fair-minded person would have to conclude that Pence won in a landslide. He was focused on his key points, while Kaine was focused on dragging the conversation into personal attacks on a man who wasn’t even standing on the stage.

The problem, obviously, is that they aren’t running for an Ohio Senate seat.

They’re running for vice president. Or at least Tim Kaine is. That’s why he loyally defended Clinton when Pence hit the Clinton Foundation issue instead of pivoting away to his own talking points. He played the somewhat awkward role of loyal number two. Pence, by contrast, focused on making Mike Pence look good and happily left Trump’s eccentricities on the cutting board.

Tim Kaine is running for Vice President in 2016. Mike Pence is running for president in 2020. — Jon Lovett (@jonlovett) October 5, 2016

For Republicans sitting at home, Pence’s largely effective performance should serve as a powerful reminder that a generic Republican candidate would probably win the 2016 election. Trump, by contrast, is losing currently, has been losing from the beginning, and probably will lose in the end.

When he does, Republicans will be searching for their next nominee. When they do, they’ll see that Pence — the guy I used to think they would pick for 2016 — doesn’t quite have the pizzazz or superstar quality of a Donald Trump, but he’s also a much better, more focused, more disciplined, less crazy politician. The kind of guy who could actually win.

Watch: This election is about normal vs. abnormal