WASHINGTON — US House Speaker John Boehner wrapped up a visit to Afghanistan Wednesday and assailed President Barack Obama's plan to begin pulling US troops out in July a risk to fragile security gains.

"Any drawdown of US troops must be based on the conditions on the ground, not on political calculations," Boehner, the White House's top Republican foe in the US Congress, said in a statement from his office in Washington.

"If the Obama administration insists on beginning to draw down troops in July, it must explain how the pace and scope of such a move will not undermine the tenuous progress we've made thus far. To date, it has not done so."

Boehner's comments came at the end of a two-day visit to Afghanistan, during which the congressional delegation he led heard from US General David Petraeus, US commander of foreign forces in Afghanistan.

"During our meeting with General Petraeus, he noted that security gains have been made in Afghanistan, but that they are fragile and reversible," said the speaker, the third-ranking US elected official.

"That is why we must remain steadfast in our commitment to the counterinsurgency strategy our commanders on the ground have put in place and to ensuring its success, rather than focusing on meeting arbitrary deadlines for withdrawal," said Boehner.

The group also heard from other top military officials as well as US Ambassador Karl Eikenberry and from Afghan President Hamid Karzai, who has drawn fire from Washington on issues like corruption.

"It's also clear that there are immense challenges in building a credible government on behalf of the Afghan people. We heard from President Karzai about his efforts to do so," said Boehner.

The speaker said the visiting lawmakers got an "on-the-ground perspective" and stressed that "while the conditions remain difficult in Afghanistan, our troops are making gains in their efforts to improve security and prevent al-Qaeda and the Taliban from using the region as a safe haven.

The delegation included Republican Representatives Mac Thornberry, Mike Conaway, Tom Rooney and Joe Heck -- all members of the House Armed Services Committee -- and Democratic Representative Dan Boren, a member of the House Intelligence Committee.