By Phil Stewart

MADRID (Reuters) - U.S. Defense Secretary Ash Carter pledged on Sunday a full, transparent investigation into whether the U.S. military could be linked to the destruction of an Afghan hospital run by aid group Medecins Sans Frontieres (MSF) that killed 22 people.

But Carter, as he embarked on a trip to Europe, cautioned that the situation on the ground was confused, investigators were not at the scene, and it would time to gather facts in the Afghan city of Kunduz, the site of fierce fighting.

"We do know that American air assets ... were engaged in the Kunduz vicinity, and we do know that the structures that -- you see in the news -- were destroyed," Carter told reporters traveling with him shortly before landing in Spain.

"I just can't tell you what the connection is at this time."

MSF on Sunday demanded an independent international inquiry, branding the attack a "war crime" and saying a U.S. military probe into the incident was not enough.

U.S. officials, speaking on condition of anonymity, say a U.S. military AC-130 gunship had been operating in the area, firing at Taliban targets after receiving a request for support from U.S. special operations forces advising Afghan troops.

The U.S. military has said American forces carried out an air strike in Kunduz city at 2:15 a.m. local on Saturday.

"The situation there is confused and complicated. So it may take some time to get the facts but we will get the facts and we will be full and transparent about sharing them," Carter said.

Carter refused to speculate on what occurred but stressed that the United States would hold accountable "anybody responsible for doing something they shouldn't have done."

Asked whether the United States would rule out further air strikes in Kunduz, Carter said the decision on what support to provide was up to the commander in Afghanistan, U.S. Army General John Campbell.

"General Campbell will take whatever actions he thinks are appropriate," Carter said.

Story continues

Battles were still raging on Sunday around Kunduz, a city of 300,000, as U.S.-backed government forces sought to drive out the Taliban militants who seized the city almost a week ago.

The fighting came just as Washington weighs whether to slow a drawdown of the nearly 10,000 U.S. forces in Afghanistan. Campbell has drawn up options that include keeping thousands of troops in the country beyond 2016, U.S. officials say.

(Additional reporting by Mirwais Harooni and Andrew MacAskill in Kabul; Editing by Eric Walsh)