WASHINGTON — 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.

Nearing the end of his 4½-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.

The move to end the ban on openly gay military service could be one of Gates’ final acts as defense chief. But he 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.

Under the repeal law signed in December, the “don’t ask, don’t tell” policy won’t be off the books until 60 days pass after the president, the defense secretary and the chairman of the Joint Chiefs of Staff certify that the U.S. military is ready. If Gates approves the certification before he leaves office, the repeal could be fully implemented in September.