WASHINGTON (AP) -- Mitt Romney hit an off note when he told a "humorous" story about his dad shutting down a factory.
Robert De Niro managed to get both Newt Gingrich and the Obama campaign riled up when he joked at an Obama fundraiser that America isn't ready for a white first lady.
Texas Gov. Rick Perry, still nursing wounds from his failed presidential campaign, did himself a world of good with his self-deprecating jokes at a recent Washington dinner.
Done right, humor can be a huge asset for a politician. But it is fumbled easily in the overheated environment of a political campaign.
That may be why Romney's aides sent him to the "The Tonight Show" this past week with these instructions: "Don't try and be funny."
The Republican presidential front-runner largely complied, and that worked out just fine for him. But he apparently forgot his advisers' advice the next day when he attempted to be funny on a conference call with people in next-to-vote Wisconsin.
Romney recounted what he called a "humorous" story about the time his auto executive father shut down a factory in Michigan and moved it to Wisconsin. Later, when his dad was in a parade while running for Michigan governor, the marching band kept playing the University of Wisconsin fight song.
"Every time they would start playing 'On, Wisconsin! On Wisconsin!' my dad's political people would jump up and down and try to get them to stop," Romney said with a laugh.
A joke about closing factories? In this economy? What was he thinking?
Democrats pounced on it as fresh evidence that Romney is out of touch with the economic concerns of ordinary voters.
Jokes that might be funny another time often don't pass muster under the klieg lights of a presidential campaign.
De Niro attempted satire during a New York fundraiser headlined by Michelle Obama this month when he ticked off the names of the wives of the GOP presidential candidates and then joked that America wasn't "ready for a white first lady."
Donors roared their approval. But by the next morning, Gingrich was calling the racial reference to the Republican wives "inexcusable" and the chastened Obama campaign was labeling the actor's comments "inappropriate."
De Niro at first declined to comment but ended up apologizing -- sort of.
"My remarks, although spoken with satirical jest, were not meant to offend or embarrass anyone -- especially the first lady," he said in a statement.
President Barack Obama, for his part, has had better luck using humor to deflect questions about his own vulnerabilities -- real or perceived.
During a St. Patrick's Day reception this month, Obama was presented with a certificate of Irish heritage by the Irish prime minister.
"This will have a special place of honor alongside my birth certificate," Obama deadpanned, deftly sending the message that any lingering doubts about where he was born are nothing but a joke.
Sometimes, humor can come back to bite a candidate long after the laugh lines have faded.
In 2004, when Romney was Massachusetts governor, he took a jab at the wealth of that year's monied presidential candidate, Democratic Sen. John Kerry.
"There's a senator from my state, you may have heard, that wants to get elected president," Romney said at a Republican Governors Association dinner. "And I don't know why he wants to do that because, of course, if he won he'd have to move into a smaller house."
It may have been funny then, but the joke boomeranged when it resurfaced on the Internet this past week just as Romney is trying to combat an elitist image.
Perry, whose Republican presidential campaign quickly floundered in the primaries, took a big step toward rehabilitating his image with his appearance last weekend at a fancy Washington dinner for journalists and their guests.
He got plenty of laughs when he joked that his time as the GOP front-runner had been "the three most exhilarating hours of my life."
He perfectly skewered Romney by quipping that during the GOP debates, he'd been tempted to turn to his rival and ask, "Pardon me, do you have any Grey Poupon?"
Getting off a few well-rehearsed jokes -- often written by someone else -- is generally less challenging than displaying pitch-perfect humor day after day amid the grind of campaigning. Perry's jokes, for example, were written by GOP speechwriter Landon Parvin.
But even some of the most carefully thought-out jokes, in the end, just aren't funny.
Take President George W. Bush, at a White House Correspondents Association dinner in 2004. He narrated a slide show that included a photo of himself hunting around in the Oval Office and then quipped, "Those weapons of mass destruction gotta be somewhere."
Critics said it was a callous joke, given all those who had died in the Iraq war.
Even some candidates with a natural funny bone have found that it doesn't always translate well to a presidential campaign.
Republican Sens. Bob Dole and John McCain, whose humor was a hit with congressional colleagues and reporters, both discovered their sometimes wicked sense of humor could be too cutting for a presidential campaign.
Morris Udall, a Democratic congressman from Arizona, got more laughs than votes in his 1976 run for president and ended up writing a memoir titled, "Too Funny to be President."
On the other hand, some decidedly unfunny candidates have benefited by exceeding extremely low expectations.
When candidate Richard Nixon went on the TV comedy show "Rowan & Martin's Laugh-In" in 1968 and said "Sock it to ME?" he got rave reviews.
Associated Press writers Ben Feller, Charles Babington and Laurie Kellman contributed to this report.
Follow Nancy Benac on Twitter: http://www.twitter.com/nbenac