A dozen American troops were shot today, including two Special Forces members who were killed, when a gunman dressed as an Afghan policeman opened fire on them in one of the worst days for the U.S. military in recent months.

The attacked triggered a firefight on the base, officials said. Three Afghans were also killed and a dozen wounded, U.S. authorities said.

Tensions between U.S. troops and Afghans were further complicated in a separate incident today when U.S. troops killed two Afghan civilians in Bagrami District, just outside of Kabul. The civilians were killed as their vehicle was approaching a military convoy. A coalition official says an investigation is now underway.

The latest so-called insider attack came in Wardak just weeks after Afghan President Hamid Karzai called for U.S. Special Forces to leave Wardak. The Taliban claimed responsibility for the attack.

The shooting took place while the troops were visiting the facility to help train the Afghans, a key part of the U.S. handover strategy before combat troops leave in 2014.

After the attack, U.S. Special Forces immediately cordoned off the area. Afghan army leaders expressed dismay that they were not allowed inside.

Last year, more than 60 coalition troops were killed in so-called insider attacks.

The attack also comes just a day after new U.S. Secretary of Defense Chuck Hagel's trip to Afghanistan, one marred by controversy.

On Saturday, a suicide bomber on a bicycle struck just outside the Afghan Ministry of Defense, one of the most heavily fortified buildings in the country. At least nine Afghan civilians were killed. Though Hagel was in a meeting at a coalition military base at the time and never in any danger, nearby bases were put into lockdown, and reporters travelling with Hagel's press pool were ushered into a safe room in the basement of the base they were on.

Then on Sunday, Karzai implied the Taliban were serving U.S. interests by creating instability in Afghanistan. The inflammatory comments were made during a nationally televised speech.

Referring to recent insurgent attacks, including the one outside the Ministry of Defense, Karzai said the attacks were "not aimed at showing their strength to the USA, but to serve the USA.

"In fact, yesterday's bombings in the name of the Taliban were aimed at serving the foreigners and supporting the presence of the foreigners in Afghanistan and keeping them in Afghanistan, by intimidating us," Karzai said.

The top U.S. commander in Afghanistan, Gen. Joseph Dunford, quickly rejected the comments, calling them "categorically false."

"We have fought too hard over the past 12 years, we have shed too much blood over the last 12 years, to ever think that violence or instability would be to our advantage," Dunford said.

Later that evening, Hagel cancelled a scheduled joint press conference with Karzai. A spokesperson cited security concerns, though a Karzai spokesperson said it was due to "scheduling pressures." The two still held a private dinner meeting with Dunford in attendance, but the cancellation of the joint press conference was widely seen as a snub to Karzai in response to his inflammatory remarks.