Former Libyan dictator Moammar Gaddafi was killed Thursday after being seized in a sewage tunnel in his home town — the final triumph for pro-democracy fighters who have struggled for eight months to take control of the country.

Gaddafi’s death came on a day of intense military activity in Sirte, the last loyalist holdout in Libya, where his supporters had fended off better-armed revolutionaries for weeks. Before his capture, a U.S. drone and French fighter jets fired on a large, disorganized convoy leaving the city that he appears to have been in. It was not clear whether the airstrikes hit Gaddafi’s vehicles, NATO officials said.

Gaddafi was shot in the head during an exchange of gunfire between his supporters and revolutionaries as he was being whisked away from the tunnel in a truck, according to Mahmoud Jibril, the interim prime minister. But cellphone videos played on Arab-language TV stations showed an already bloodied and dazed Gaddafi being escorted to the truck, raising questions about exactly when he was hit. One of Gaddafi’s sons, Mutassim, and his army chief of staff were also killed, officials said.

The taking of Sirte and Gaddafi’s death marked the climax of a war that was backed by an unprecedented NATO air campaign aimed at protecting civilians. Thursday’s events clear the way for the appointment of a temporary government that is to steer the country toward elections.

Gaddafi, thought to be 69 when he died, ruled the country for 42 years, and he had vowed to fight to the death in Libya rather than concede defeat to a popular uprising. He was a brutal, and often unpredictable, autocrat and led this oil-rich nation virtually single-handedly, banning opposition parties and a free press and mandating study of his “Green Book,” which prescribed a supposed rule by the masses.

Gaddafi was the first leader to be killed in the Arab Spring uprisings, and photos of his blood-smeared face quickly spread across the region, sending a powerful message to both dictators and demonstrators elsewhere, much like photos of former Egyptian ruler Hosni Mubarak being hauled before a court.

Libya erupted in joy as word of his capture and death flashed across Arab-language channels. In Tripoli, celebratory gunfire was so heavy that airspace over the city was closed to traffic.

“This is the moment we were fighting for. Finally we got rid of the dictator!” exclaimed Sharif Hakim, 37, who wore the camouflage uniform of the revolutionaries and joined a singing, dancing crowd in downtown Tripoli.

Jibril said Gaddafi was not slain upon capture. Officials and fighters in Sirte, however, gave varying details during the day of how the killing occurred.

Fighters on the ground told Reuters that Gaddafi and a handful of his men appeared to run from their convoy after the NATO bombing and take shelter in two drainage pipes.

“At first we fired at them with antiaircraft guns, but it was no use,” Salem Bakeer said while being feted by his comrades near the road. “Then we went in on foot.”

The prime minister said Gaddafi was discovered with a group of supporters in a sewage pipe in Sirte, armed with a pistol and wearing pants and a long-underwear shirt — a far cry from his famously flamboyant outfits. He did not resist arrest.

As Gaddafi was being walked to a truck, however, he was shot in the right arm in an exchange of gunfire between his supporters and revolutionaries, Jibril said.

The truck then got caught in crossfire as it headed toward a hospital, and Gaddafi was shot in the head, Jibril said.

“That was the deadly shot,” he said in an interview. The former leader died shortly thereafter, he said.

But cellphone videos showed Gaddafi being loaded on a truck, blood spattered on his face and chest, suggesting he was wounded before boarding the truck.

“We got you!” revolutionaries in camouflage yelled as they crowded around the wounded former leader.

A doctor took samples from Gaddafi’s body, including blood and saliva, to confirm his identity, Jibril said. The doctor also clipped off pieces of the former dictator’s hair — only to discover he was wearing a wig, according to the prime minister.

Gaddafi’s reign ended in late August, when revolutionaries flooded the capital.

Now, the question is whether forces united in their hatred of Gaddafi can come together and govern a country that has never known democracy.

“The challenge was, and still is, to regain security in the cities,” which are effectively under the control of local militias and awash in arms, Jibril said in an interview.

Gaddafi leaves such a vacuum that interim leaders are not even sure what kind of laws they can use to try the thousands of pro-
Gaddafi prisoners detained during the conflict. Different tribes may jockey for power, and conflicts are likely between Islamists and more secular Libyans.

A NATO official said Gaddafi’s death would not necessarily mean an immediate end to alliance action in the country, adding that NATO has not yet held formal discussions on ending the mission.

“It’s not like walking out of a room and switching off the light,” the official said, speaking under alliance ground rules that he not be named. But, the official said, “now that the last area has fallen, we’re not going to see any strike missions, are we?”

President Obama called Gaddafi’s death “the end of a long and painful chapter for the people of Libya, who now have the opportunity to determine their own destiny in a new and democratic Libya.”

World leaders on Thursday called on Libyans to reconcile and not resort to revenge killings. While Gaddafi’s slaying eases fears he might be able to mount some sort of insurgency from captivity, his son and right-hand man, Saif al-Islam, remains on the run, officials said.

Gaddafi’s body was at a mosque in the city of Misurata, west of Sirte, on Thursday night. He will be buried in an undisclosed location, officials said.

The interim government is expected to officially declare the country liberated on Saturday, triggering the appointment of a new temporary government and a timetable for elections, expected in about eight months.

Officials said the ceremony may occur in Benghazi, the eastern city that was the birthplace of the revolution. There has already been tension between that city’s revolutionaries and those from other parts of the country who worry they are not getting their due in a new government.

The new government has made slow progress because of the prolonged siege of Sirte, where Gaddafi supporters put up unexpectedly strong resistance.

“We’ve been in a political no-man’s land” waiting for Sirte to fall, said Peter Cole, a Middle East analyst in Libya. That has fed infighting among the militias, he said.

Jibril said he was relieved that Gaddafi was dead. Still, he said, he would have preferred that the former leader had survived to stand trial

“I wish he was caught, and I would be the prosecutor,” he said. “I just want to ask him one question: Why?”

Staff writers Greg Jaffe in Washington and Michael Birnbaum in Berlin and special correspondent Ayman al-Kekly in Tripoli contributed to this report.