"For the first time since 9/11 we have a chance to achieve the mission that we are embarked upon," Panetta said. "To achieve that mission will require a continued commitment, continued perseverance, continued partnership and continued sacrifice on the part of our nations."
He told Karzai that his country should not doubt U.S. resolve to prevent the Taliban from regaining power and potentially facilitating al-Qaida's return.
"America will not turn away from Afghanistan," he said.
The Pentagon chief, who is expected to step down early in 2013 and return to private life, also made a plea for Pakistan to do more to clear al-Qaida, the Taliban and other extremist groups from havens on its side of the border with Afghanistan.
He said Pakistani leaders have often promised to take action, "but have not followed through." Without such action, peace and security in Afghanistan will remain elusive, Panetta said.
Another major issue facing Panetta in the closing weeks of his tenure is how many U.S. troops to withdraw from Afghanistan in 2013 and 2014. There currently are 66,000 in the country, down from a peak of about 100,000 in 2011.
U.S. Army Maj. Gen. Robert Abrams, commander of international forces in four southern provinces, including the key province of Kandahar, told reporters Thursday that he foresees further troop cuts in coming months, but he did not specify whether he was talking only about U.S. troops.
"I fully expect by next summer we will have less ISAF forces here because we'll need less ISAF forces," Abrams said, using the acronym for the U.S.-led International Security Assistance Force. He said believes fewer will be needed because Afghan forces will be more capable by then.