TRIPOLI, Libya (AP) -- During nearly 42 years in power in Libya, Moammar Gadhafi was one of the world's most eccentric dictators, so mercurial that he was both condemned and courted by the West, while he brutally warped his country with his idiosyncratic vision of autocratic rule until he was finally toppled by his own people.
The modern Arab world's longest-ruling figure, Libya's "Brother Leader" displayed striking contrasts. He was a sponsor of terrorism whose regime was blamed for blowing up two passenger jets, who then helped the U.S. in the war on terror. He was an Arab nationalist who mocked Arab rulers. In the crowning paradox, he preached a "revolutionary" utopia of people power but ran a one-man dictatorship that fueled the revolution against him.
His death on Thursday at age 69 - confirmed by Prime Minister Mahmoud Jibril - came as Libyan fighters defeated Gadhafi's last holdouts in his hometown of Sirte, the last major site of resistance in the country in an eight-month civil war.
Interim government officials said his son, Muatassim, a former national security adviser, was also killed in Sirte on Thursday. Another, British-educated Seif al-Islam - widely seen as being groomed as a successor - was captured with a gunshot wound to the leg.
The final declaration of victory by Gadhafi's opponents came weeks after he was swept from power by rebels who drove triumphantly into the capital of Tripoli on Aug. 21.
"Dance, sing and fight!" Gadhafi had exhorted his followers even as his enemies were on the capital's doorstep before fleeing into Libya's hinterlands where his die-hard backers had continued to battle the rebels-turned-rulers.
Gadhafi leaves behind an oil-rich nation of 6.5 million traumatized by a rule that drained it of institutions while the ship of state was directed by the whims of one man and his family. Notorious for his extravagant outfits - ranging from white suits and sunglasses to military uniforms with frilled epaulets to brilliantly colored robes decorated with the map of Africa - he styled himself as a combination Bedouin chief and philosopher king.
He reveled in infuriating leaders, whether in the West or the Middle East. U.S. President Ronald Reagan, after the 1986 bombing that killed U.S. servicemen in Berlin was blamed on Libya, branded him a "mad dog." Former Egyptian President Anwar Sadat, who fought a border war with Libya in the 1970s, wrote in his diary that Gadhafi was "mentally sick" and "needs treatment."
Behind the flamboyance and showmanship, associates say Gadhafi was meticulous in managing the levers of power. He intervened in decisions large and small and constantly met personally with tribal leaders and military officers whose support he maintained through lucrative posts.
The sole constant was his grip on the country. Numerous coup and assassination attempts against him over the years mostly ended with public executions of the plotters, hanged in city squares.
The ultimate secret of his longevity lay in the vast oil reserves under his North African desert nation and in his capacity for drastic changes of course when necessary.
The most spectacular U-turn came in late 2003. After years of denial, Libya acknowledged responsibility - though in a Gadhafi-esque twist of logic, not guilt - for the 1988 bombing of Pan Am Flight 103 over Lockerbie, Scotland, that killed 270 people. He agreed to pay up to $10 million to relatives of each victim.
He also announced that Libya would dismantle its nuclear, chemical and biological weapons programs under international supervision.
The rewards came fast. Within months, the U.S. lifted economic sanctions and resumed diplomatic ties. The European Union hosted Gadhafi in Brussels. Secretary of State Condoleezza Rice in 2008 became the highest-ranking U.S. official to visit the country in more than 50 years. Tony Blair, as British prime minister, visited him in Tripoli.
International oil companies rushed to invest in Libya's fields. Documents uncovered after Gadhafi's fall revealed close cooperation between his intelligence services and the CIA in pursuing terror suspects after the 9/11 attacks, even before the U.S. lifted its designation of Libya as a sponsor of terror in 2006.
Still, Gadhafi's renegade ways did not change. After Swiss police had the temerity to briefly arrest his son Hannibal for allegedly beating up two servants in a Geneva luxury hotel in 2008, Gadhafi's regime arrested two Swiss nationals and raked Switzerland over the coals, extracting an apology and compensation before finally releasing the men nearly two years later. European countries, eagerly building economic ties with Libya, did little to back up Switzerland in the dispute.
But Gadhafi became an instant pariah once more when he began a brutal crackdown on the February uprising in his country that grew out of the Arab Spring of popular revolts across the region. The U.N. authorized a no-fly zone for Libya in March, and NATO launched a campaign of airstrikes against his military forces.
"I am a fighter, a revolutionary from tents. ... I will die as a martyr at the end," he proclaimed in one of his last televised speeches during the uprising, pounding the lectern near a sculpture of a golden fist crushing a U.S. warplane.
Gadhafi was born in 1942 in the central Libyan desert near Sirte, the son of a Bedouin father who was once jailed for opposing Libya's Italian colonialists. The young Gadhafi seemed to inherit that rebellious nature, being expelled from high school for leading a demonstration, and disciplined while in the army for organizing revolutionary cells.
In 1969, as a mere 27-year-old captain, he emerged as leader of a group of officers who overthrew the monarchy of King Idris. A handsome, dashing figure in uniform and sunglasses, Gadhafi took undisputed power and became a symbol of anti-Western defiance in a Third World recently liberated from its European colonial rulers.
During the 1970s, Gadhafi proceeded to transform the nation.
A U.S. air base was closed. Some 20,000 Italians were expelled in retaliation for the 1911-41 occupation. Businesses were nationalized.
In 1975 he published the "Green Book," his political manifesto that laid out what he called the "Third International Theory" of government and society. He declared Libya to be a "Jamahiriya" - an Arabic neologism he created meaning roughly "republic of the masses."
Everyone rules, it declared, calling representative democracy a form of tyranny, and Libyans were organized into "people's committees" that went all the way up to a "People's Congress," a sort of parliament.
In the end, rule by all meant rule by none except Gadhafi, who elevated himself to colonel and declared himself "Brother Leader."
"He aspired to create an ideal state," said North African analyst Saad Djebbar of Cambridge University. "He ended up without any components of a normal state. The 'people's power' was the most useless system in the world."
In the 1970s and 1980s, Gadhafi supported groups deemed by the West to be terrorists - from the Irish Republican Army through various radical Palestinian units to militant groups in the Philippines. He embarked on a series of military adventures in Africa, invading Chad in 1980-89, and supplying arms, training and finance to rebels in Liberia, Uganda and Burkina Faso.
A 1984 incident at the Libyan Embassy in London entrenched his regime's image as a lawless one. A gunman inside the embassy opened fire on a demonstration by Gadhafi opponents outside, killing a British policewoman.
The heat was rising, meanwhile, between the Reagan administration and Gadhafi over terrorism. In 1986, Libya was found responsible for a bombing at a Berlin discotheque frequented by U.S. troops in which three people died. America struck back by sending warplanes to bomb Libya. About 40 Libyans died.
The Lockerbie bombing followed in 1988, followed a year later by a bombing that downed a French airliner over the West African nation of Niger. The West was outraged, and years of sanctions followed.
Libya's road back from pariah status began in 1999, when Gadhafi's government handed over two Libyans for trial in the Lockerbie bombing. In 2001, a Scottish court convicted one, an intelligence agent, and sentenced him to life imprisonment. The other was acquitted.
In 2002, Gadhafi looked back on his actions and told a crowd of Libyans in the southern city of Sabha: "In the old days, they called us a rogue state. They were right in accusing us of that. In the old days, we had a revolutionary behavior."
Throughout his rule, he was a showman who would stop at nothing to make his point.
His appearances at Arab League summits were an annual cause of cringing among fellow Arab rulers. At one, he argued vehemently with Saudi Arabia's King Abdullah, winning the monarch's eternal hatred. At another, Gadhafi smoked cigars on the conference hall floor during speeches to show his contempt.
In a 2009 address at the United Nations, he rambled on about jet lag, then tore up a copy of the U.N. charter, saying the Security Council "should be called the terrorism council."
On state trips, he would insist on setting up a tent to stay in. He sported a personal escort of female guards - which he once explained by saying: "There are no men in the Arab world."
A 2009 U.S. diplomatic cable released by the website WikiLeaks spoke of Gadhafi's intense dislike of staying on upper floors of buildings, aversion to flying over water, and taste for horse racing and flamenco dancing.
"At night, Moammar dreams; by day, he implements," Libyans would say, referring to the bizarre rules Gadhafi would randomly impose on the country, like demanding all storefront doors be painted green, the signature color of his regime. Or like complaining that Libyans were going abroad for medical treatment and deciding it was because of a lack of Libyan doctors - so he ordered Tripoli's main medical school to take 2,000 new students regardless of qualifications, well beyond its 150-student capacity.
He even renamed the months, calling the cold month of January "Ayn al-Nar," Arabic for "Where is the Fire."
In the past decade, power was increasingly concentrated with his eight biological children, who snapped up elite military posts or lucrative business positions. They all fled into hiding when Tripoli fell.
Son Seif al-Islam at one time seemed to be a Western-leaning reformer but threw in his lot with his father after the uprising began. Muatassim, who was killed Thursday, led a military unit in a crackdown on protesters.
Two other sons, Saif al-Arab, was killed earlier during the uprising, and another, Khamis, was believed killed.
His only daughter, Aisha, who became a lawyer and helped in the defense of Saddam Hussein, Iraq's toppled dictator, in the trial that led to his hanging.
Gadhafi's wife Safiya, fled to neighboring Algeria or Niger.
Gadhafi did spend oil revenue on building schools, hospitals, irrigation and housing on a scale his Mediterranean nation had never seen.
"He did really bring Libya from being one of the most backward and poorest countries in Africa to becoming an oil-rich state with an elaborate infrastructure and with reasonable access by the Libyan population to the essential services they required," said George Joffe of Cambridge University.
Still, about a third of Libya's people remain in poverty. Gadhafi showered benefits on parts of the country, such as Tripoli. Meanwhile, eastern Libya, ultimately the source of February's rebellion, was allowed to atrophy.
Keath reported from Cairo. Christopher Gillette in Sirte and Rami al-Shaheibi in Tripoli contributed to this report.