After serenading the first lady with the words, "I love you, I love you, I love you," McCartney joked that he just might be the "first guy ever to be punched out by a president."
The president didn't seem to mind though: He was swaying along to the beat while his wife mouthed the words along with McCartney.
The 90-minute concert was built around Obama's presentation to McCartney of the Gershwin Prize for Popular Song, awarded by the Library of Congress. The president said McCartney had "helped to lay the soundtrack for an entire generation."
McCartney, 67, said it was a moment like no other.
"I don't think there could be anything more special than to play here," the Englishman said.
And then he volunteered to make it a regular gig.
"Lunchtimes, we could come around," he offered. "We're cheap."
The concert featured an all-star lineup of top performers doing their own interpretations of some of McCartney's greatest hits. McCartney said it was inspiring to see what other people did with his music.
Among those performing were Stevie Wonder, the Jonas Brothers, Faith Hill, Elvis Costello, Emmylou Harris, Herbie Hancock, White Stripes singer and guitarist Jack White, pianist Lang Lang and Foo Fighters frontman Dave Grohl.
The Gershwin prize is named for the songwriting brothers George and Ira Gershwin. Previous recipients are Wonder and Paul Simon.
Those not lucky enough to snag tickets to the East Room gig can catch the concert July 28, when it's televised on PBS' "In Performance at the White House."