It might have been a barking dog, or a crashed drone, or overheard chatter on walkie talkies. But multiple military and intelligence sources told NBC News that something tipped off the terrorist targets of an early-morning raid by the U.S. and its allies in Yemen on Sunday, and all hell broke loose.

A well-rehearsed mission that was supposed to extract computers and other intelligence from an al Qaeda camp near a mountain village turned into a massive firefight involving Harrier jets, helicopter gunships and gun-wielding jihadi women that killed one Navy SEAL, 14 al Qaeda fighters and, allegedly, non-combatant women and children.

According to a senior military official, one of the dead was an 8-year-old American girl, the daughter of U.S.-born al Qaeda leader Anwar al-Awlaki, who himself was killed in a U.S. strike in Yemen in 2011.

President Donald Trump and his daughter Ivanka Trump walk toward Marine One while departing from the White House. Trump made an unannounced trip to Dover Air Force base in Delaware to pay his respects to Chief Special Warfare Operator William "Ryan" Owens, who was killed during a raid in Yemen. Mark Wilson / Getty Images

President Donald Trump declared Sunday’s mission a success, and the Pentagon released a statement Wednesday that said U.S. forces had captured "materials and information that is yielding valuable intelligence."

But a senior military official told NBC News "almost everything went wrong." A senior intelligence official with direct knowledge of the operation said it’s not yet clear if the mission was a success. "We went in with the intent of capturing phones and computers and we don’t know yet if anything of great value was obtained," the official said.

"Who fired first? What was actually gathered? What went wrong?" a senior former special operations officer asked rhetorically. "These kinds of assessments just don’t come in Twitter time. We’ll have to wait and see."

Preparing for the Raid

The raid, according to multiple military and intelligence officials and a post-battle briefing paper shared with NBC News, had been planned and prepared for months, and was part of a long multinational campaign to weaken the foothold of al Qaeda in the Arabian Peninsula (AQAP), long considered one of the most dangerous arms of the terrorist organization.

AQAP has a history of attacks against the U.S. and its allies, including the Christmas Day 2009 attempted bombing of a commercial airliner in the United States, the failed parcel bomb plot of 2010 and the January 2015 Charlie Hebdo office attack in Paris.

The U.S. has been trying to dismantle AQAP since 2002. In addition to drone and air strikes — there were a half dozen drone strikes in 2016 — the U.S. has also used boots on the ground. Small numbers of U.S. military personnel have engaged in unilateral operations against AQAP leaders and in support of Yemeni and coalition special operations forces.

The U.S. began preparations for Sunday’s raid on the al Qaeda camp months ago, according to a senior military official. The intent of the "site exploitation" mission was to capture important information about a terror network’s personnel and supplies from a specific house in the al Qaeda camp near Ghabat Yakla in south Yemen.

Planning was intense, with almost three months of intelligence collection — including "pattern of life" constant surveillance of the target home and the families in nearby dwellings.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Because the targeted house was particularly well guarded, officials say, the "package size," or the volume of troops and materiel needed, was larger than usual.

In early December, the USS Makin Island and its amphibious readiness group, including other ships and Marines, arrived in the area to serve as the quick reaction force for American operations in Yemen. They were joined in Djibouti by the Navy SEALs who would make up the main raiding party.

On Dec. 21, the SEALs joined the Marines in a helicopter-borne training raid in Djibouti, an exercise that served as a rehearsal for Sunday’s mission.

The Obama administration then had to decide whether to carry out the mission.

A former senior Obama administration official said that plans for the raid were presented to the Obama national security team before the inauguration as part of a menu of potential actions that represented a significant expansion of U.S. activity in Yemen. After a full interagency review, the official said, the Obama administration decided to pass the decision on the series of operations off to the Trump administration, since they would have to commence under the new president.

Related: Trump Turns Attention to Yemen, But Is Looking at Iran

The hesitation, the official said, related to the number of troops that would be involved and that the plans represented a wider use of ground troops than the U.S. had previously considered in Yemen. The official said the specific raid mounted on Sunday was not presented for a decision.

White House spokesman Sean Spicer said Wednesday that the raid was approved in an interagency deputies meeting on Jan. 6, and that the plan called for the raid to take place on a moonless night, which meant it would occur after Trump’s inauguration.

The former Obama official, however, said the interagency deputies committee of the National Security Council did not officially recommend for or against the raid.

Ned Price, a former CIA officer who was spokesman for the National Security Council during the Obama administration, said in a tweet that Spicer was wrong and that the "specific operation in question was never presented to or considered by the Obama Admin for approval."

Except it was misleading. The specific operation in question was never presented to or considered by the Obama Admin for approval. https://t.co/v0KwnhhRj9 — Ned Price (@nedprice) February 2, 2017

According to a former special operations officer with knowledge of the raid, one of the Obama administration’s concerns was the integration of commandos from the United Arab Emirates, an unusual arrangement for the Joint Special Operations Command (JSOC) and its elite task forces. In some ways, said the retired officer, it was an Emirati-driven operation, with their intelligence on the ground and their year-long preparation.

The Firefight

Early Sunday, SEALS from SEAL Team 6 and Emirati commandos converged on a landing zone eight kilometers from the village, according to the briefing paper and a senior military official. Their target was the heavily guarded house where AQAP leaders were temporarily living, reportedly with computer and communications equipment of value to the ongoing campaign.

They walked around five miles to their objective.

Then, said officials, something tipped the targets off to their approach. Depending on the account, it might have been a barking dog, or Emiratis intercepted speaking in Arabic on walkie talkies, or the crash of a small Emirati drone surveying the target from a forward position.

"Initial reports are always wrong, but it doesn’t appear to be a failure of planning or intelligence," said the former special forces officer.

Almost immediately, the raiding force on the ground took intense fire, according to the briefing paper and a senior military official. Occupants of the targeted house and its compound, along with their guard force, moved to a separate cluster of houses nearby where families, including women and children, were staying. Armed women fired on the U.S. and Emirati forces.

"There were a lot of female combatants who were part of this," said Navy Capt. Jeff Davis, the Pentagon’s chief spokesman, on Monday. "We saw during this operation, as it was taking place, that female fighters ran to pre-established positions — as though they had trained to be ready, and trained to be combatants — and engaged with us."

The raiding force began to take casualties. Chief Petty Officer William "Ryan" Owens, a veteran member of the elite team, was hit and would die of his wounds. The SEALs called for backup, and for a medical chopper.

An MV-22 Osprey, intended for transport and rescue, flew to the landing zone eight kilometers from the firefight. But a hard landing injured several of the passengers and damaged the craft so badly it was no longer airworthy.

A pair of Harrier jets and a pair of helicopter gunships arrived from the USS Makin Island and joined the battle. The jets bombed and strafed the al Qaeda encampment, and the choppers fired on the target with their cannons.

"This complex situation included small arms fire, hand grenades and close air support fire," U.S. Central Command (CENTCOM) said Wednesday night in a written statement.

"The known possible civilian casualties appear to have been potentially caught up in aerial gunfire that was called in to assist U.S. forces in contact against a determined enemy that included armed women firing from prepared fighting positions, and U.S. special operations members receiving fire from all sides to include houses and other buildings."

Fifty minutes after the raiding team reached the village, the firefight was over. Owens was dead, and at least six American service members were injured. The Osprey chopper, a $70 million aircraft, was destroyed by a U.S. bomb. The U.S. left with communications equipment, and said that three of the 14 enemy combatants killed were top AQAP leaders.

An image of 8-year-old Nora Anwar Al-Awlaki, who was killed in a raid in Yemen ordered by President Trump. Yemeni media / via Twitter

The grandfather of 8-year-old Nawar al-Awlaki is among those who say that non-combatant casualties were high. The girl received U.S. citizenship through her father Anwar al-Awlaki, a radical cleric who was born in New Mexico and lived in the U.S. for a total of 20 years. Her grandfather said she was killed by gunfire during the raid, and her picture has circulated throughout the Arab world.

On Monday, Capt. Jeff Davis had advised that observers should "take reports of female casualties with a grain of salt. Not all female casualties are civilian casualties in many cases, and certainly with this one."

But on Wednesday, the Pentagon said that it is continuing to investigate civilian casualties and what went wrong. It has already concluded "regrettably that civilian non-combatants were likely killed" during the raid, and that the casualties may include children.