TRIPOLI, Libya — Col. Muammar el-Qaddafi, the former Libyan strongman who fled into hiding after rebels toppled his regime two months ago in the Arab Spring’s most tumultuous uprising, was killed Thursday as fighters battling the vestiges of his loyalist forces wrested control of his hometown of Surt, the interim government announced.

Al Jazeera television showed what it said was Colonel Qaddafi’s corpse as jubilant fighters in Surt fired automatic weapons in the air, punctuating an emphatic and violent ending to his four decades as a ruthless and bombastic autocrat who basked in his reputation as the self-styled king of kings of Africa.

Libyans rejoiced as news of his death spread. Car horns blared in Tripoli as residents poured into the streets to celebrate.

Mahmoud Shammam, the chief spokesman of the Transitional National Council, the interim government that replaced Colonel Qaddafi’s regime after he fled Tripoli in late August, confirmed that Colonel Qaddafi was killed, though he did not provide other details.

"A new Libya is born today," he said. "This is the day of real liberation. We were serious about giving him a fair trial. It seems God has some other wish."

Abdul Hakim Belhaj, the leader of the Tripoli military council, said on Al Jazeera that anti-Qaddafi forces had Colonel Qaddafi’s body.

It was not clear precisely how he died. Mohamed Benrasali, a member of the national council’s Tripoli Stabilization Committee, said fighters from Misurata who were deployed in Surt told him that Colonel Qaddafi was captured alive in a car leaving Surt. He was badly injured, with wounds in his head and both legs, Mr. Benrasali said, and died soon after.

.

Colonel Qaddafi had defied repeated attempts to corner and capture him, taunting his enemies with audio broadcasts denouncing the rebel forces that felled him as stooges of NATO, which conducted a bombing campaign against his military during the uprising under the auspices of a Security Council mandate to protect Libyan civilians.

Libya’s interim leaders had said they believed that some Qaddafi family members including the colonel himself and some of his sons had been hiding in Surt or in Bani Walid, another loyalist bastion that the anti-Qaddafi forces captured earlier this week.

There was no immediate comment on the news of his death from American officials. .

Victoria Nuland, the State Department spokeswoman, traveling with Secretary of State Hillary Rodham Clinton in Afghanistan, said the department was aware of the reports “on the capture or killing of Muammar Qaddafi.”

There was also no immediate comment from Mustafa Abdel-Jalil, the interim government’s top official. But he had said that the death or capture of Colonel Qaddafi would allow him to declare the country liberated and in control of its borders, and to start a process that would lead to a general election for a national council within eight months.

Libyan fighters said earlier on Thursday that they had routed the last remaining forces loyal to Colonel Qaddafi from Surt, ending weeks of fierce fighting in that Mediterranean enclave east of Tripoli.

A military spokesman for the interim government, Abdel Rahman Busin, said, “Surt is fully liberated.”

The battle for Surt was supposed to have been a postscript to the Libyan conflict, but for weeks soldiers loyal to Colonel Qaddafi, fiercely defended the city, first weathering NATO airstrikes and then repeated assaults by anti-Qaddafi fighters. Former rebel leaders were caught off guard by the depth of the divisions in western Libya, where the colonel’s policy of playing favorites and stoking rivalries has resulted in a series of violent confrontations.

Surt emerged as the stage for one of the war’s bloodiest fights, killing and injuring scores on both sides, decimating the city and leading to fears that the weak transitional leaders would not be able to unify the country.

The battle turned nearly two weeks ago, when the anti-Qaddafi fighters laid siege to an enormous convention center that the pro-Qaddafi troops had used as a base.

The interim leaders had claimed that the ongoing fighting had prevented them from focusing on other pressing concerns, including the proliferation of armed militias that answered to no central authority.

Steven Lee Myers contributed reporting from Kabul, Afghanistan, and J. David Goodman and Rick Gladstone from New York.