U.S. Defense Secretary Leon Panetta, right, speaks with U.S. Ambassador to Afghanistan Ryan Crocker, center, and the head of NATO coalition forces in Afghanistan, Gen. John Allen, upon his arrival at Kabul International Airport in Afghanistan on June 7. (Jim Watson/AP)

Afghan President Hamid Karzai on Thursday publicly condemned a U.S. airstrike a day earlier that Afghan officials said had killed 18 civilians — a blunt reproach that coincided with a visit to the Afghan capital by Defense Secretary Leon E. Panetta.

“NATO operations that inflict human and material losses to civilians can in no way be justifiable, acceptable and tolerable,” Karzai said in a statement. He had returned early from a trip to China to further address the incident, which occurred in Logar province, about 50 miles from Kabul.

The backlash comes at critical moment in U.S.-Afghan relations, just weeks after the signing of a bilateral strategic partnership agreement and as leaders of both countries attempt to outline the specifics of American military involvement here beyond 2014.

Panetta and Afghan Defense Minister Abdul Rahim Wardak were speaking to journalists in Kabul when Karzai released his statement condemning the Wednesday attack. Both men emphasized joint progress made in the fight against the Taliban but expressed frustration about what they described as a continuing undisturbed haven for insurgents in Pakistan.

“We are reaching the limits of our patience here,” Panetta said. “And for that reason, it is extremely important that Pakistan take action to prevent this kind of safe haven.”

Later Thursday, Pakistan’s ambassador to the United States, Sherry Rehman, criticized Panetta’s comment, saying that it would make it harder for the two countries to narrow their differences, the Reuters news agency reported.

“It adds an unhelpful twist to the process and leaves little oxygen for those of us seeking to break a stalemate,” Rehman said in a statement.

Nine children and four women were among those killed in the Logar airstrike, provincial spokesman Mirwais Mirzakwal said. Officials described the operation as a joint effort between coalition and Afghan forces.

Karzai called a relative of the victims from China, where he was participating in the Shanghai Cooperation Organization summit, and pledged a thorough investigation of what happened. NATO officials said they are investigating as well.

The coalition “is taking the allegations seriously,” said Martyn Crighton, a spokesman for NATO forces. “As a part of that process, the commander has dispatched a team to gather facts, meet with Afghan officials and try to determine what happened.”

Hours after the airstrike, two suicide bombers attacked a Kandahar market, killing at least 22 civilians. The two incidents made Wednesday one of the bloodiest days for Afghans in the history of the war.

Panetta called Wednesday’s suicide attack “much more organized than we’ve seen before.” According to witnesses, the first bomber on a motorcycle attacked a parking lot often used by NATO supply vehicles in southern Kandahar; a second bomber detonated explosives as others tried to help the wounded.

Panetta came to Afghanistan to confer with military leaders on plans to withdraw troops and deal with rising violence. He noted that despite the increase in bloodshed in recent weeks, overall violence was lower than in previous years.

“We have a tough fight on our hands,” Panetta said. He reaffirmed the United States’ long-term commitment to Afghanistan and said he believed it would help thwart the Taliban’s goals.

In comments before his arrival, Panetta said the purpose of his visit was “to get a sense of just exactly what are the Taliban doing” and to hear an assessment from U.S. commanders of how NATO will deal with the Taliban and the Haqqani network operating from Afghanistan and Pakistan.

“I think it’s important to make sure we are aware of the kind of attacks they’re going to engage in as we go through the rest of the summer,” he said.

Panetta began the four-hour stopover by meeting with U.S. Ambassador Ryan Crocker and the U.S. commander of NATO-led forces, Marine Corps Gen. John Allen, who must withdraw 23,000 U.S. troops by the end of September, leaving 68,000 in the country.

According to the Obama administration’s plan, the vacancies left by those departures will be filled by Afghan forces and U.S. advisory teams whose performance will determine how commanders proceed with continued withdrawals until the end of 2014.

Special correspondent Sayed Salahuddin contributed to this report.