A U.S. soldier aims his rifle at a doorway after coming under fire by the Taliban while on patrol in Kandahar province, southern Afghanistan, in April 2012. (Baz Ratner/Reuters)

Two American service members were killed in Afghanistan on Wednesday, the U.S. military said, a day after an unannounced visit to the country by Secretary of State Mike Pompeo.

The military did not immediately provide any details of the deaths but indicated the service members were killed in combat. The Taliban insurgent group claimed responsibility, saying the two Americans were slain in an ambush in Wardak province, about 60 miles southwest of Kabul.

The deaths were reported three days ahead of a seventh round of U.S.-Taliban talks scheduled for June 29 in Qatar.

“The names of the service members killed in action are being withheld until 24 hours after notification of next of kin is complete,” the U.S.-led NATO mission in Afghanistan said in a statement.

Speaking to reporters Wednesday in New Delhi, Pompeo called the deaths “tragic,” adding: “I think this drives home the need for us to be successful” in negotiating an end to Afghanistan’s decades of violence.

The U.S. goal in Afghanistan “is a reconciliation, to reduce the level of violence, to reduce the level of risk to Afghans broadly and the risk to American service members,” he said. “So, I think what you’ll see is a continued push by the United States to achieve the reconciliation, the reduction in risk that the president set out as the mission set for the State Department and for the United States government.”

In his brief visit to Kabul on Tuesday, Pompeo met with President Ashraf Ghani, Chief Executive Abdullah Abdullah and former president Hamid Karzai to discuss the need for a peaceful settlement to end nearly 18 years of warfare in Afghanistan involving the United States.

“Afghans yearn for peace and we share their desire to end the conflict,” he wrote on Twitter after the visit. “Peace would offer Afghans and the wider region a different future, one which we are ready to support.”

Pompeo said in Kabul that the U.S. government hopes to reach a peace deal before Sept. 1.

Taliban fighters continue waging war, targeting Afghan government and foreign forces across the country despite engaging in a wide range of negotiations with U.S. officials and Afghan power brokers.

But the Taliban has refused to meet directly with Ghani’s government, disparaging him as a “stooge” of the Americans.

The two deaths Wednesday bring this year’s total of U.S. troop deaths in Afghanistan to 10, according to iCasualties, a website that tracks casualties of U.S. forces in Afghanistan and Iraq.

In April, three U.S. service members and a contractor were killed in car-bomb attack outside Bagram airfield, the largest U.S. military base in the country. The Taliban claimed responsibility for that attack.

More than 2,400 U.S. service personnel have died in Afghanistan since American forces intervened in the country after the Sept. 11, 2001, attacks on the United States, which were carried out by the al-Qaeda terrorist organization then based in Afghanistan under Taliban protection. Before U.S. airstrikes helped Afghan resistance forces drive the Taliban from Kabul in November 2001, the country had been beset by almost continuous warfare since the late 1970s, including a decade-long occupation by Soviet forces in the 1980s.

Branigin reported from Washington. Carol Morello in New Delhi contributed to this report.