President Obama on Wednesday appointed Joseph P. Clancy, who had guided the Secret Service on an interim basis for the last four and a half months, to be the agency’s permanent director.

In picking Mr. Clancy, a former head of Mr. Obama’s security detail, the president rejected calls by critics on Capitol Hill and members of a special Department of Homeland Security panel, who said that a string of embarrassing personnel and security episodes had made it clear that the agency should be run by an outsider.

Mr. Obama, who has more at stake than anyone in how the Secret Service operates, has told associates that while the agency has had some problems, he does not believe it has widespread problems and needs a complete overhaul. The president was said to be impressed with Mr. Clancy’s personnel moves in recent months, including the demotion of several senior officials.

Mr. Clancy “has demonstrated that he was willing to conduct a candid, cleareyed assessment of the shortcoming of that agency, and to look at needed reforms and implement them,” said the White House press secretary, Josh Earnest. “And that, precisely, is why he has been promoted to this permanent role.”

Some Secret Service officials and agents had worried that Mr. Obama was going to choose the other leading candidate for the job: Sean Joyce, a hard-charging former deputy director of the F.B.I. In the Secret Service’s 150-year history, it has always been run by someone who was previously an agent.

In December, a four-person panel created by the Department of Homeland Security released a report that said the Secret Service’s next director should be “removed from organizational traditions and personal relationships” and “be able to do the honest, top-to-bottom assessment this will require,” making it seem unlikely that Mr. Clancy would get the job.

And in recent weeks, the agency’s most ardent critic on Capitol Hill, Representative Jason Chaffetz, Republican of Utah and chairman of the House Committee on Oversight and Government Reform, asserted again that the next director should come from outside the agency. Mr. Chaffetz released a statement Wednesday afternoon criticizing Mr. Obama’s decision.

“The panel made it crystal clear that only a director from outside the agency would meet the needs of the agency today — someone with a fresh perspective, free from allegiances and without ties to what has consistently been described as a ‘good-old-boys network,’ ” he said.

Later, Mr. Chaffetz said he was not satisfied that the Secret Service’s problems had been solved and released a joint letter with the committee’s ranking Democrat, Representative Elijah E. Cummings of Maryland, saying that the panel would continue its investigation of the agency.

Video

Some background on the chain of mistakes at the Secret Service and the importance of leadership as the agency tries to get past its difficult stretch.CreditCreditDoug Mills/The New York Times

After leading Mr. Obama’s security detail for much of his first term, Mr. Clancy retired in 2012 to become the head of security at Comcast in Philadelphia. The next year, he told administration officials that he was not interested in being a candidate to fill the vacancy left by the Secret Service’s longtime director, Mark J. Sullivan, who was retiring. But last fall, the president called on Mr. Clancy to run the agency after Julia A. Pierson resigned as director amid criticism of the agency’s failure to stop a man from entering the White House after he climbed over its fence.

At the time, Mr. Clancy told others he had no interest in becoming the permanent director. But in an interview early in his tenure as interim director, he said that, though he had previously believed the agency might benefit from having an outsider in charge, he had determined after leading it for a short period of time that the learning curve would be too steep for someone who had not been an agent.

As the head of Mr. Obama’s security detail, Mr. Clancy spent countless hours by the president’s side, protecting him as he crisscrossed the country and the world. Thousands of photos of Mr. Obama from his first term show Mr. Clancy’s face in the background. Along with having a strong trust in Mr. Clancy, who is known as affable, the president is said to like him personally.

His appointment comes at a particularly important time for the Secret Service. This year, along with protecting the first family and senior government officials, it will oversee security for a visit by Pope Francis, the 70th United Nations General Assembly and the beginning of the 2016 presidential campaign.

Mr. Clancy has significant challenges ahead of him, according to the report produced by the four members of the Department of Homeland Security panel appointed to study the Secret Service after the White House fence jumper made it into the building in September.

The agency, the report said, is “stretched to and, in many cases, beyond its limits,” and needs to hire 85 agents and 200 uniformed officers to properly perform its mission.

“Perhaps the service’s great strength — the commitment to its personnel to sacrifice and do the job ‘no matter what’ — has had unintended consequences,” the report said.

Money that should be spent on new technology systems often goes to pay overtime for overworked agents and officers at the White House, the report said, adding, “Rather than sending its agents and officers to training, it keeps them at their posts.”

In 2013, the average officer received about 25 minutes of training, the report said.

The fence around the White House, which the report said needed to be “changed as soon as possible” to be several feet taller, still has not been altered.

Agency officials said that changes to the fence were under review and that they required the approval of several other organizations, like the White House Historical Association and the United States Park Police.

A version of this article appears in print on , Section A, Page 14 of the New York edition with the headline: Obama Makes Interim Secret Service Chief Permanent. Order Reprints | Today’s Paper | Subscribe