Said Obama: "Contrary to the rumors you have heard, I was not born in a manger. I was actually born on Krypton and sent here by my father, Jor-el, to save the planet Earth," a reference to Superman.
McCain joked that Democrats had already begun attacking Joe the Plumber, the Ohio man whom he referred to in Wednesday night's debate, and claimed "that this honest, hardworking small businessman could not possibly have enough income to face a tax increase under the Obama plan."
"What they don't know is that Joe the Plumber recently signed a very lucrative contract with a wealthy couple to handle all the work on all seven of their houses," McCain said, drawing laughter with the reference to his property holdings.
The two men spoke at the 63rd annual Alfred E. Smith Memorial Foundation Dinner, a charity event organized by the Catholic Archdiocese of New York for the benefit of needy children. An estimated $4 million was raised.
The event often draws politicians as speakers and, by long tradition, presidential candidates appear as headliners every four years. In this case, the evening of humor came one night after an intense final debate of the presidential campaign.
McCain lampooned Obama's primary opponent, Hillary Rodham Clinton, as well as himself.
"Even in this room full of proud Manhattan Democrats, I can't shake the feeling that some people here are pulling for me," he said, before adding: "I'm delighted to see you here tonight, Hillary."
He also said Obama "is ready for any contingency, even the possibility of a sudden and dramatic market rebound. I'm told that at the first sign of a recovery, he will suspend his campaign and fly immediately to Washington to address the crisis," said the Republican, who drew criticism when he suspended his campaign a few weeks ago and flew to Washington during the crisis.
Obama also poked fun at his Democratic National Convention acceptance speech, which he delivered before a crowd of tens of thousands at an outdoor football stadium on an elaborately constructed stage.
"I was originally told we'd be able to move this outdoors to Yankee Stadium," he said of the dinner.
Then, pausing and looking around, he said, "Could somebody tell me what happened to the Greek columns that I requested?"
Both men closed with compliments.
McCain praised Obama for his "great skill, energy, and determination. It's not for nothing that he's inspired so many folks in his own party and beyond," he said of his rival, bidding to become the nation's first black president. "I can't wish my opponent luck but I do wish him well."
Obama said few Americans had served their country with "the same honor and distinction" as McCain, a former Navy pilot who was a prisoner of war for more than five years in Vietnam.