Defense Secretary Robert Gates said Monday that he sees no roadblocks to ending the ban on openly gay military service, and if the top officers of each service recommend moving ahead on the repeal before the end of the month, he will endorse it.

A little over two weeks before ending his 4 1/2 year tenure as Pentagon chief, Gates sat down in his office for an Associated Press interview that touched on a range of issues, including his expectation of a smooth handoff to his designated successor, current CIA Director Leon Panetta. Gates will retire June 30. Panetta's Senate confirmation is expected shortly.

Gates sounded a cautiously optimistic note about developments in troubled Yemen, where the government and opposition tribes have engaged in armed clashes, pushing the country toward civil war. Gates said things have calmed down a bit since President Ali Abdullah Saleh left for neighboring Saudi Arabia on June 5 for medical treatment of wounds he suffered in an attack on his compound in Yemen.

"I don't think you'll see a full-blown war there," Gates said. "With Saleh being in Saudi Arabia, maybe something can be worked out to bring this to a close," by finding an accommodation among Saleh's family, the opposition tribes and the military.

The move to end the ban on gay services could be one of Gates' final acts as defense chief. But Gates stressed that he is not trying to hurry the process along, and that if it is not ready by the end of the month, Panetta can take action when he steps in.

More than a million U.S. troops have been trained on the new law that repealed the 17-year-old ban on gays serving openly in the armed services, and Gates said the instruction has gone well.

"I think people are pretty satisfied with the way this process is going forward," he said. "I think people have been mildly and pleasantly surprised at the lack of pushback in the training."

Still, he noted that decades after women entered military service, there are still persistent problems with sexual assaults. So, the notion that there will be no ugly incidents when the ban is lifted is "unrealistic," he said.

Under the law passed last December and the detailed process laid out this year by the Pentagon, the military chiefs report to Gates every two weeks on training progress and must eventually make a recommendation on whether the repeal will damage the military's ability to fight.

If Gates approves the certification before he leaves office, the repeal could be fully implemented in September.

Gates said the most common question that has arisen during the troops' training has been on military housing. He said commanders are developing ways to deal with that.

On Afghanistan, Gates said Americans should be reassured that the White House is making another "deep dive" review of the situation as part of President Barack Obama's decision on how many U.S. troops to withdraw in July. And he said he expects the Iraqi government to request that some U.S. troops remain in Iraq beyond this year.

On Pakistan, the Pentagon chief said the administration was concerned by the suspicious outcome of an effort to share U.S. intelligence about the location of militants' bomb facilities in Pakistan's tribal region.

As an act of faith to restore relations with Pakistan, U.S. intelligence in recent weeks shared the location of two such compounds believed to contain bomb material held by the al-Qaida linked Haqqani extremist network. But by the time Pakistani authorities reached the facilities, they had been vacated, Gates said.

"We don't know the specifics of what happened," he said. "There are suspicions and there are questions, but I think there was clearly disappointment on our part."

A U.S. official said Monday that after tipping off Pakistani intelligence to the location of the two compounds, U.S. drones and satellite feeds showed the militants cleared out the contents at both sites.

The official, who spoke on condition of anonymity, said the assumption was that the Pakistanis had tipped off the Haqqanis.

Asked whether it's time to take a harder line with Pakistan, Gates counseled patience and noted that the Pakistanis have not forgotten that the U.S. abandoned them in the late 1980s after the Soviets pullout out Afghanistan.

"We need each other, and this relationship goes beyond Afghanistan," he said. "It has to do with regional stability and I think we have to be realistic about Pakistani distrust ... and their deep belief that when we're done with al-Qaida that we'll be gone, again."

Despite recurring tensions between Washington and Islamabad, and questions by some in Congress about the wisdom of having spent billions of dollars on aiding Pakistan since Sept. 11, 2001, Gates said the effort has paid off.

"I think it's been a worthwhile investment on our part," he said.

Gates, who originally opposed U.S. military intervention in Libya, predicted that strongman Moammar Gadhafi will fall, "whether it's of his own volition or somebody takes care of it for him." By that Gates meant either the military or Gadhafi's own family could turn against him.

Reflecting on his imminent departure from a job he has described as the most rewarding in his long career of government service — including 27 years at the CIA — Gates said he is confident that Panetta will gain his footing quickly at the Pentagon.

"There is no lapse in terms of somebody getting up to speed on the issues," Gates said. "Essentially, Leon just changes place in the Situation Room," referring to the main crisis management room inside the White House.

"He's been in all the conversations on all the big issues, so there's just no catch-up time at all for him," he added. "And I think that's really important for the president and for the country, given where we are."

Gates, 67, who is retiring to his home in the Puget Sound area of Washington state, said without hesitation that he will miss just two things about his job.

"One is the people that I work with, and the other is the troops. I won't miss anything else."


AP National Security Writer Anne Gearan and AP Intelligence Writer Kimberley Dozier contributed to this report.


Robert Burns can be reached at http://www.twitter.com/robertburnsAP