WASHINGTON - The decision to lift the military's ban on women in combat had its roots in the experiences of Defense Secretary Leon Panetta and Gen. Martin Dempsey, the chairman of the Joint Chiefs of Staff, both men said on Thursday.

For Dempsey, it all began in Baghdad. He had just arrived there in 2003 as a division commander, he said at a Pentagon news conference, when he clambered aboard a Humvee and asked the driver where he was from. "And I slapped the turret gunner on the leg and I said, 'Who are you?'" Dempsey recalled. "And she leaned down and said, 'I'm Amanda.' "

After the chortles died down, Dempsey continued: "And I said, 'Oh, OK.' So a female turret gunner is protecting a division commander. And it's from that point on that I realized something had changed and it was time to do something about it."

Almost a decade later, Dempsey and Panetta signed a document rescinding a 1994 ban that restricted women from infantry, artillery, armor and other such combat roles. "Not everyone is going to be able to be a combat soldier," Panetta said, "but everyone is entitled to a chance."

Panetta said his thinking evolved as he traveled over the past 18 months as defense secretary to Iraq and Afghanistan and across the United States. "It's been almost 50 years since I served in the military," he said, referring to his two years as an Army intelligence officer. "And to go out now and to see women performing the roles that they are performing and doing a great job at it, I think it just encouraged me, and I think it encouraged all of us that everybody should have a chance to perform at any mission, if they can meet the qualifications."

Both Panetta and Dempsey said the new policy was in many ways an affirmation of what they had seen was already occurring on the battlefield, where women have frequently found themselves in combat over the past decade of war in Iraq and Afghanistan -- although not officially recognized for it and therefore held back in a military in which combat experience is crucial to advancement. Panetta and Dempsey said it was essential that the military offer equal opportunities to women and men.

"They're fighting and they're dying together, and the time has come for our policies to reflect that reality," Panetta said.

Panetta and Dempsey said they had met weekly for more than a year about lifting the ban and had kept President Obama informed about developments.

In December, Pentagon officials said, Panetta and the Joint Chiefs reached a tentative agreement that women should be permitted in combat. Panetta thought about it over the holidays and returned early this month to receive a letter dated Jan. 9 from Dempsey strongly recommending the change.

In the most vocal official opposition to the changes, Sen. James Inhofe of Oklahoma, who is set to become the senior Republican on the Armed Services Committee, warned that some in Congress may seek legislation to limit the combat jobs open to women.