Finally, a presidential pat on the back for the embattled U.S. Secret Service.

President Obama offered a note of praise Tuesday after the agency performed "flawlessly" during a week that included visits from Pope Francis and Chinese President Xi Jinping, as well as a gathering of more than 150 foreign delegations at the U.N. General Assembly in New York City.

Touching down on Marine One on the South Lawn, Obama paused on his way into the White House to tell reporters that he wanted to make a "special commendation" for the federal protective agency, which oversaw one of the largest operational security efforts in U.S. history over the past week.

“When something goes wrong, when there’s a fence jumper, everybody reports on it," Obama said, with the swirl of the helicopter blades making it difficult for reporters to hear him. "The Secret Service had to manage the Pope’s visit, President Xi’s visit, and a hundred something world leaders in an unprecedented fashion during the course of the last several days. And they did so flawlessly."

The Secret Service's reputation has been tarnished after a string of public embarrassments that began with a prostitution scandal during Obama's trip to a summit in Cartagena, Colombia, in 2012. The successive incidents, which include a fence-jumper making his way into the White House last fall, led to the departure of two directors before retired agent Joseph Clancy was brought back earlier this year.

Obama has been mostly supportive of the Service, despite its failings. He referred to a "couple of knuckleheads" after the prostitution scandal but said that should not detract from the work the agency does to keep him and his family safe.

On Tuesday, Obama singled out Clancy, who had served as his first protective detail leader at the White House in 2009, for praise.

"And Joe Clancy, the head of the Secret Service, and the entire team and detail and professional services, they all deserve a huge round of applause for being such great hosts and keeping everybody safe," Obama said. "So I just wanted to make sure everybody heard that."

The massive inter-governmental effort around the pope's visit was among the largest in U.S. history, and there were not major security lapses in Washington, New York and Philadelphia, despite hundreds of thousands of people lining public streets and parks to see Francis.