WASHINGTON (AP) — Defense Secretary Leon Panetta warned Congress Tuesday that the budget stalemate and lawmakers' spending choices are among the greatest threats to the U.S. military today, increasing the stress on the force and making it difficult to fund programs that best keep troops ready to fight.

Speaking as lawmakers try to wrap up negotiations on a defense bill, Panetta said defense officials have built a budget that tries to protect military readiness while also providing needed services to troops who have been involved in wars for more than 11 years.

"Nevertheless, there is pressure on the department to retain excess force structure and infrastructure instead of investing in the training and equipment that makes our force agile and flexible and ready," said Panetta, during a wide-ranging speech at the National Press Club. "Aircraft, ships, tanks, bases, even those that have outlived their usefulness have a natural political constituency. Readiness does not. What's more, readiness is too often sacrificed in favor of a larger and less effective force. I am determined to avoid that outcome."

He complained that lawmakers have taken about $74 billion in proposed budget savings and diverted them to programs the Pentagon doesn't need.

And Panetta said the current impasse over how to avoid the "fiscal cliff" of tax hikes and more than $1 trillion in automatic spending cuts could inflict lasting damage on America's national defense.

If the automatic cuts are not avoided, the Pentagon could face about $500 billion in across-the-board budget reductions, he said. Failure to find a solution "will weaken this nation in the minds of our allies, our partners, and our potential adversaries, and undermine the work and the sacrifices that our troops are making every single day."

While Panetta also offered an optimistic view of the Afghanistan war, he said that other threats to the U.S. — from al-Qaida-linked terrorists and cyberattacks to hostile powers such as Iran — are growing.

"The threats to our security and our global interests are not receding, as they appeared to do in past wars, coming out of World War II, coming out of Korea, coming out of Vietnam, coming out of the end of the Cold War, where the threats receded," Panetta said. "The fact is today we still confront these threats in the world, threats that are more complex, more dispersed, and in many ways, more dangerous."

Just days after he returned from his most recent trip to Afghanistan, Panetta spoke optimistically about the war effort there. He said the international military coalition has managed to reverse a five-year trend of growing violence and that Afghan forces are on track to take the lead for securing the entire country next year.

And, he said, military commanders "believe that we have fundamentally turned the tide in that effort, after years in which we lacked the right strategy and the necessary resources to try to achieve the mission we are embarked on."

.Panetta spent two days in Afghanistan last week, consulting with top American commanders and with Afghan government officials. He announced during his visit that President Hamid Karzai will come to Washington next month to meet with President Barack Obama to discuss the way ahead.

By all accounts, Panetta is in the final weeks of his tenure as Pentagon chief. He has long said he intends to return to California where his wife Sylvia continues to work at the Panetta Institute for Public Policy, which they founded in 1977.

Chuck Hagel, a former Republican U.S. senator from Nebraska, is considered the leading contender for the job as Panetta's successor.