ARLINGTON, Va. (AP) — Calling it “the honor of my life,” Defense Secretary Leon Panetta said farewell to the U.S. military Friday, capping a venerated public service career that spanned four decades and included stints as a lawmaker, a top White House official and the spy chief who oversaw the killing of Osama bin Laden.

President Barack Obama, honoring his first-term Pentagon chief at a ceremony at a military base outside Washington, said Panetta would be remembered for welcoming more Americans into the military by opening combat roles to women and overseeing the repeal of a ban on gays serving openly — “In short, for making our military and our nation that much stronger.”

“Every decision he has made has been with one goal in mind: taking care of our sons and our daughters in uniform and keeping America safe,” Obama said.

Panetta, the son of immigrants and self-described son of Italy, said he hoped in some small way to have helped to fulfill the dreams of his parents. As he spoke, row upon row of U.S. troops stood behind him, rifles and bayonets at their sides.

“It’s been, for me, a hell of a ride,” said Panetta, who served in Congress and in the Clinton administration before becoming Obama’s CIA director and ultimately serving a brief but pivotal term as defense secretary.

“I will never forget the pride and exhilaration when I walked out of the White House after the president announced the success of the bin Laden operation,” he recalled. “I could hear the chants of those people who were gathered around the White House and in Lafayette Park yelling, ‘U.S.A. U.S.A.”’

Looming awkwardly over the formal farewell ceremony was the ongoing uncertainty about Panetta’s replacement.

Obama has nominated former Nebraska Sen. Chuck Hagel, a Republican, to take over for Panetta, but Republicans have expressed deep misgivings about his previous statements about Iran, Israel and other issues. Days after postponing a vote on Panetta’s confirmation amid GOP demands for more information, the Democratic chairman of the Senate’s military panel said Friday he will press ahead with a vote.

Making no reference to the political hurdles, Obama said Hagel’s mission would be to keep the U.S. military prepared and described Hagel as “a combat veteran with the experience, judgment and vision that our troops deserve.”

Panetta has said he will remain on the job until the Senate confirms a successor. Then he will finally leave the Pentagon, returning home to his walnut farm in Carmel, Calif., after more than 40 years in Washington.

Panetta’s tenure at the Pentagon was marked both by major milestones and a series of obstacles he and the military had to work to overcome. He oversaw the military’s formal exit from Iraq and the start of the last drawdown of troops in Afghanistan, plus the end of a successful NATO campaign to rid Libya of Moammar Gadhafi.

But his attention was also diverted by prostitution scandals, spikes in sexual assaults and suicides, and ethical lapses by a handful of senior military leaders. An ongoing battle over spending cuts prompted Panetta to warn continually of the dire consequences of an underfunded military. Even as Panetta continued the efforts against al-Qaida, the threat from the terrorist group expanded in places like North Africa.