WASHINGTON  A Beatle met the president when Sir Paul McCartney performed at the East Room of the White House on Wednesday night.

Accepting the Library of Congress Gershwin Prize for Popular Song, Mr. McCartney used the occasion to applaud President Obama. “Getting this prize would be good enough,” Mr. McCartney said. “But getting it from this president ...” He smiled.

He added that despite “difficult times” for the president, “you have billions of us who are rooting for you.” Then, with the first lady in the front row, Mr. McCartney sang “a song I have been itching to do at the White House,” he said. It was “Michelle.”

A few minutes after the concert, Mr. McCartney returned to the microphone, thanking the Library of Congress and adding, “After the last eight years, it’s great to have a president who knows what a library is.”