NEW YORK — Joe Biden on Wednesday night alternated between humor and solemnity when he was pressed several times by comedian Stephen Colbert on the frequency with which he commits gaffes, offering another defense of his erroneous story about pinning a medal on a soldier in Afghanistan.

During the 22-minute interview on “The Late Show With Stephen Colbert” — Biden’s first appearance on a late-night television show since he announced his presidential campaign — Colbert ran through a raft of Biden’s verbal miscues.

Biden said he was in Vermont when he was in New Hampshire. He placed the 1968 assassinations of Martin Luther King Jr. and Robert F. Kennedy in the 1970s.

“You assured us, ‘I’m not going nuts,’ ” Colbert continued. “Follow up question: Are you going nuts?”

The Washington Post’s Matt Viser analyzes a string of recent gaffes by Democratic presidential candidate Joe Biden and what they might mean in 2020. (JM Rieger/The Washington Post)

Biden paused a beat and responded, “The reason I came on the Jimmy Kimmel show is …”

Colbert asked whether it was unfair to criticize Biden for his gaffes.

“I think it’s fair to go after a political figure for anything. Okay? I mean we’re — we stand up and that comes with the territory,” Biden said. “But here’s the deal. Any gaffe that I have made — and I’ve made gaffes just like any politician I know has — have been not about a substantive issue.”

Biden then referred to his story about a soldier, which — as The Washington Post reported last week — never happened and appeared to be a conflation of facts from at least three actual events.

The Post article detailed Biden’s account, which he recently relayed to a crowd in New Hampshire: In it, he says that as vice president, he made a risky flight into Afghanistan’s dangerous Konar province to pin a Silver Star on a Navy captain who had rappelled down a 60-foot ravine to retrieve the body of an American comrade and carry him up on his back.

None of those facts was true. Some of Biden’s story seemed to stem from a 2011 ceremony in which he pinned a Bronze Star on an Army staff sergeant who received the award for trying to pull a fellow soldier’s body from a burning vehicle in a different province in Afghanistan.

Shortly after The Post article was published, Biden cast doubt on its accuracy: “I don’t know what the problem is. What is it that I said wrong?” he asked in an interview with Post columnist Jonathan Capehart.

“They said that the branch of the military was wrong,” Colbert told Biden. “And that the date was wrong. And the act it was awarded for was wrong. And the medal was wrong.”

The crowd began to chuckle.

“I was not talking about me, I was praising … the valor of all these people out there that I visited in over 20 visits in Afghanistan and Iraq,” Biden responded. “And I’ve watched these people, and I’ve watched what they’ve done. And I was pointing out the young man who I did pin the medal on in Wardak province — he didn’t want the medal because his buddy had been killed as he was being dragged out of a burning Humvee. He said, ‘Don’t pin it on me.’ ”

Biden said that despite the errors, he got the essence of the story correct.

“Look, it’s a different thing to say when you’re talking about honoring the bravery or the sacrifice or what other people went through,” Biden said. “And the essence of it is absolutely true.”

Biden appeared to still get some details wrong on Wednesday. He said that he pinned a medal on an unwilling soldier twice, once as vice president-elect and once as a senator. The Post was able to locate only one soldier, who received a medal from Biden in 2011, when Biden was vice president.

He went on a trip to Afghanistan as a senator, but in the days after his return, he recounted watching then as a two-star general pinned a medal on a soldier. He also went as vice president-elect on a trip to Kabul to meet with Hamid Karzai, then the president of Afghanistan. That trip did not include a visit to a forward operating base, as Biden described.

“The fact that I said that I was vice president — well, in one case I was vice president-elect. The other case, I was a senator,” he said. “I’m not sure that’s relevant but I don’t, you know, I don’t get wrong things like you know there is — we should lock kids up in cages at the border.”

When Colbert pressed Biden on a recent comment he made to NPR, saying that “details are irrelevant,” Biden responded, “Those details are irrelevant. The point I was making is absolutely accurate.”

“But some details are relevant — that’s where the devil is, is in the details,” Colbert said.

“The devil lives in the details if the details that you’re talking about would affect the outcome of something that’s about to happen, or should happen,” Biden answered. “And the idea that, you know, I made the case that these folks are heroes and we shouldn’t treat them as that, and we should be thankful to them.”

When the conversation turned to another topic, Biden said that he talks regularly with former president Barack Obama and that their last conversation was about three or four weeks ago. When asked whether he would nominate Obama to the Supreme Court were he to become president, Biden said, “He’s fully qualified. Fully qualified.”

Asked whether he had approached former first lady Michelle Obama for advice, Biden quipped, “Only to be my vice president.”

At the start of his appearance on the show, when asked what was new, Biden quipped, “Nothing much. There’s no global warming, so don’t worry about that. Everything’s going well. The nation is in great shape. And the rest of the world is looking at us with envy.”

Toward the end, Biden was asked about electability, which has become a central component of his campaign pitch.

“Look, I’ve been around a long time,” Biden said. “The good and the bad news is all these people think they know me. They know a lot about me. They know the things that are real about me. They know that things aren’t real. And so it’s a lot harder for people to go out and make a case that I’m this or that when people know me. I’ve been around for all these years. A lot of me they don’t like, some of it they do like.”

Biden had appeared on Colbert’s show in September 2015, and Colbert encouraged him at the time to run for president. But in a raw and emotional moment during that visit, Biden said that he still felt conflicted and broken after the death of his son, Beau.

As he does at times on the campaign trail, Biden had in 2015 connected with Colbert over shared experiences of grief. Biden’s first wife and daughter died in a car accident decades before his son’s death, and Colbert’s father and two of his brothers died in a plane crash when he was a young boy.

“You and I talked about this … when my son was going through some tough times, after he passed,” Biden said Wednesday. “You said I should run. And so that’s why I’m running. It’s your fault.”