WASHINGTON — When former President George W. Bush returned to the White House on Thursday to unveil his official portrait, he brought along his wife, Laura; his parents, George and Barbara; daughters, Jenna and Barbara; and a couple of hundred cheering and whooping former staff members.


“Behave yourselves,” a grinning Mr. Bush said to the audience, which included his longtime political guru Karl Rove and former Defense Secretary Donald H. Rumsfeld. Turning to President Obama with a look of mock chagrin, Mr. Bush said, “Thank you so much for inviting our rowdy friends to my hanging.”


That wisecrack was one of a series uncorked by the 43rd president, who was making a rare re-emergence into the glare of TV cameras. And it captured the peculiar nature of this White House ritual, in which the president and his predecessor are meant to banish partisanship in favor of civility, bonhomie and even grace.


Mr. Obama, whose re-election bid is based on stoking fears of returning to the failed policies of Mr. Bush, praised his predecessor as having “extraordinary strength and resolve” after the Sept. 11 attacks. Americans, he said, will never forget the image of him standing atop the rubble of the World Trade Center, bullhorn in hand.


“Plus,” Mr. Obama said, smiling at Mr. Bush, “you also left me a really good TV sports package. I use it.”


It was not clear whether Mr. Obama was lauding or tweaking Mr. Bush when he recalled the chaotic months after the 2008 election. “We wouldn’t know until later just how breathtaking the financial crisis had been,” he said.


Then the president invited Mr. and Mrs. Bush to the stage, where they lifted black sheets to unveil portraits by a Texas artist, John Howard Sanden. Mr. Bush is depicted in the Oval Office before one of his favorite artworks, a 1929 Western painting, “A Charge to Keep,” which he used as the title for his memoir. Mrs. Bush is depicted in a midnight-blue gown, standing in the Green Room, which she helped refurbish in 2007.


Mr. Bush thanked Mr. Obama and his wife, Michelle, for their hospitality in feeding 14 members of the Bush family. He steered clear of substantive remarks about Mr. Obama’s presidency, instead jesting about how the White House collection would now start and end with a George W. (the other being George Washington).


He reminded Mrs. Obama that when British soldiers set fire to the White House in 1814, another first lady, Dolley Madison, saved the portrait of the first George W. “Now, Michelle,” he said, gesturing to his newly unveiled painting, “if anything happens, there’s your man.” And he told Mr. Obama that as he wrestled with tough decisions, he could always “gaze at this portrait and ask, ‘What would George do?’ ”


Mr. Bush’s voice caught once, when he paid tribute to his father, “Number 41,” who he said “gave me the greatest gift possible: unconditional love.” Former President George Bush sat in the front row in a wheelchair.


Mrs. Bush got off a few good lines of her own, telling Mrs. Obama that “nothing makes a house a home like having portraits of its former occupants staring down at you from the walls.” And Mrs. Obama noted approvingly that Jenna and Barbara were “just a mess,” wiping away tears as they watched their parents.


In addition to Mr. Rove and Mr. Rumsfeld, the audience included former Secretary of State Colin L. Powell; Alberto R. Gonzales, the former attorney general; and Andrew Card, who served as chief of staff. Mr. Rove sat in the second row, exchanging pleasantries with Vice President Joseph R. Biden Jr.


But Mr. Bush was clearly the big draw. He has been in something of a self-imposed political exile since he left office, offering only a fleeting endorsement of Mr. Romney — “I’m for Mitt Romney,” he said to ABC News — as the doors of his elevator closed after a speech in Washington.


Mr. Bush offered his predecessor, Bill Clinton, a similarly gracious unveiling in 2004. But earlier in history, the presidential historian Michael Beschloss noted: “You had presidents hiding the portraits of predecessors they didn’t like. In recent years instead, this has become a rare presidential ritual of national bipartisanship.”