Gaffe machine Joe Biden has put his foot in his mouth again, telling a war story on the campaign trail about pinning a medal on a hero service member’s chest — but getting nearly every detail of the yarn wrong, according to a report Thursday.

During a campaign appearance last Friday, Biden told how a four-star general had asked the then-veep to travel to Afghanistan, a dangerous trip into “godforsaken country,” to honor the heroism of a Navy captain, The Washington Post reported.

The 76-year-old Democratic presidential frontrunner said Obama administration advisers tried to talk him out of the perilous journey into a combat zone — but that he insisted on making the trip.

“We can lose a vice president,” he said. “We can’t lose many more of these kids. Not a joke.”

The Navy captain, Biden recalled, had rappelled into a 60-foot ravine under fire and recovered the body of a comrade, carrying him on his back, and the general wanted Biden to pin a Silver Star on the reluctant American hero.

“He said, ‘Sir, I don’t want the damn thing!’ ” Biden said, his voice rising with emotion.

“’Do not pin it on me, sir! Please, sir. Do not do that! He died. He died!’” Biden related as the room fell silent.

“This is the God’s truth,” Biden insisted. “My word as a Biden.”

But virtually every detail was wrong, the paper reported, adding that Biden apparently conflated several actual events to come up with his story.

Biden had visited Afghanistan in 2008, but as a senator, not as vice president, and the military man who performed the rescue was a 20-year-old Army specialist, not a Navy captain.

And that soldier, Kyle J. White, never had a Silver Star or any other medal pinned on his chest by Biden.

At a White House ceremony six years after Biden’s visit, White stood at attention as President Obama placed a Medal of Honor around his neck.

One part of Biden’s tale actually happened, sort of.

The veep once did pin a medal on a soldier, Army Staff Sgt. Chad Workman, who didn’t believe he deserved the award.

Later Thursday, Biden sounded confused about the events surrounding his story during an interview with The Post & Courier of South Carolina.

“I don’t understand what they’re talking about, but the central point is it was absolutely accurate what I said,” Biden told the paper, adding that he had not read the DC paper’s report.

“He refused the medal. I put it on him, he said, ‘Don’t do that to me, sir. He died. He died,’ ” he protested.

“It’s ridiculous … that there’s anything I said about that that wasn’t the essence of the story. The story was that he refused the medal because the fella he tried to save —and risked his life saving — died,” Biden said.

“That’s the beginning, middle and end. The rest of you guys can take it and do what you want with it.”