Three American service members and a U.S. contractor were killed when their convoy hit a roadside bomb on Monday near the main U.S. base in Afghanistan, the U.S. forces said. The Taliban claimed responsibility for the attack.

The U.S. and NATO Resolute Support mission said the four Americans were killed near the Bagram Air Base, north of Kabul, while three others were wounded in the explosion. The base in Bagram district is located in northern Parwan province and serves as the main U.S. air facility in the country.

The wounded were evacuated and are receiving medical care, the statement said. It added that in accordance with U.S. Department of Defense policy, the names of service members killed in action were being withheld until after the notification of next of kin.

In their claim of responsibility, the Taliban said they launched the attack and that one of their suicide bombers detonated his explosives-laden vehicle near the NATO base. The conflicting accounts could not be immediately reconciled.

On Tuesday, local officials said at least five Afghan civilians were wounded in the commotion after the attack on the American convoy. Four were passers-by and the fifth was a driver of a car going down the road, said Abdul Raqib Kohistani, the Bagram district police chief. Abdul Shakor Qudosi, the district administrative chief in Bagram, said American soldiers opened fire immediately after their convoy was bombed.

Monday's U.S. fatalities bring to seven the number of U.S. soldiers killed so far this year in Afghanistan, underscoring the difficulties in bringing peace to the war-wrecked country even as Washington has stepped up efforts to find a way to end the 17-year war, America's longest.

There are about 14,000 U.S. forces in Afghanistan, supporting embattled Afghan forces as they struggle on two fronts — facing a resurgent Taliban who now hold sway over almost half the country and also the Islamic State affiliate, which has sought to expand its footprint in Afghanistan even as its self-proclaimed "caliphate" has crumbled in Syria and Iraq.

Last year, 13 U.S. service members were killed in Afghanistan.

The Taliban have continued to carry out daily attacks on Afghan security forces despite holding several rounds of peace talks with the United States in recent months. The Taliban have refused to meet with the Afghan government, which they view as a U.S. puppet.

Meanwhile, the Taliban have agreed to take part in an all-Afghan gathering later this month in Qatar, where the insurgents maintain a political office. But the Taliban say they will not recognize any government official attending the gathering as a representative of the Kabul government, only as an individual Afghan participant.