TRIPOLI, Libya (AP) -- Euphoric Libyan rebels took control of most of Tripoli in a lightning advance Sunday, celebrating the victory in Green Square, the symbolic heart of Moammar Gadhafi's regime. Gadhafi's defenders quickly melted away as his 42-year rule crumbled, but the leader's whereabouts were unknown and pockets of resistance remained.
State TV broadcast Gadhafi's bitter pleas for Libyans to defend his regime. Opposition fighters captured his son and one-time heir apparent, Seif al-Islam, who along with his father faces charges of crimes against humanity at the International Criminal Court in the Netherlands. Another son was under house arrest.
"It's over, frizz-head," chanted hundreds of jubilant men and women massed in Green Square, using a mocking nickname of the curly-haired Gadhafi. The revelers fired shots in the air, clapped and waved the rebels' tricolor flag. Some set fire to the green flag of Gadhafi's regime and shot holes in a poster with the leader's image.
The startling rebel breakthrough, after a long deadlock in Libya's 6-month-old civil war, was the culmination of a closely coordinated plan by rebels, NATO and anti-Gadhafi residents inside Tripoli, rebel leaders said. Rebel fighters from the west swept over 20 miles (30 kilometers) in a matter of hours Sunday, taking town after town and overwhelming a major military base as residents poured out to cheer them. At the same time, Tripoli residents secretly armed by rebels rose up.
When rebels reached the gates of Tripoli, the special battalion entrusted by Gadhafi with guarding the capital promptly surrendered. The reason: Its commander, whose brother had been executed by Gadhafi years ago, was secretly loyal to the rebellion, a senior rebel official Fathi al-Baja told The Associated Press.
Al-Baja, the head of the rebels' political committee, said the opposition's National Transitional Council had been working on the offensive for the past three months, coordinating with NATO and rebels within Tripoli. Sleeper cells were set up in the capital, armed by rebel smugglers. On Thursday and Friday, NATO intensified strikes inside the capital, and on Saturday, the sleeper cells began to rise up.
President Barack Obama said Libya is "slipping from the grasp of a tyrant" and urged Gadhafi to relinquish power to prevent more bloodshed.
"The future of Libya is now in the hands of the Libyan people," Obama said in a statement from Martha's Vineyard, where he's vacationing. He promised to work closely with rebels.
By the early hours of Monday, opposition fighters controlled most of the capital. The seizure of Green Square held profound symbolic value -- the plaza was the scene of pro-Gadhafi rallies organized by the regime almost every night, and Gadhafi delivered speeches to his loyalists from the historic Red Fort that overlooks the square. Rebels and Tripoli residents set up checkpoints around the city, though pockets of pro-Gadhafi fighters remained. In one area, AP reporters with the rebels were stopped and told to take a different route because of regime snipers nearby.
Abdel-Hakim Shugafa, a 26-year-old rebel fighter, said he was stunned by how easy it was. He saw only about 20 minutes of gunbattles as he and his fellow fighters pushed into the capital at nightfall.
"I expect Libya to be better," said Shugafa, part of a team guarding the National Bank near Green Square. "He (Gadhafi) oppressed everything in the country -- health and education. Now we can build a better Libya."
In a series of angry and defiant audio messages broadcast on state television, Gadhafi called on his supporters to march in the streets of the capital and "purify it" of "the rats." He was not shown in the messages.
His defiance raised the possibility of a last-ditch fight over the capital, home to 2 million people. Government spokesman Moussa Ibrahim claimed the regime has "thousands and thousands of fighters" and vowed: "We will fight. We have whole cities on our sides. They are coming en masse to protect Tripoli to join the fight."
But it seemed that significant parts of Gadhafi's regime and military were abandoning him. His prime minister, Al-Baghdadi Al-Mahmoudi, fled to a hotel in the Tunisian city of Djerba, said Guma el-Gamaty, a London-based rebel spokesman.
NATO Secretary-General Anders Fogh Rasmussen said Gadhafi's regime was "clearly crumbling" and that the time to create a new democratic Libya has arrived.
It was a stunning reversal for Gadhafi, who earlier this month had seemed to have a firm grip on his stronghold in the western part of Libya, despite months of NATO airstrikes on his military. Rebels had been unable to make any advances for weeks, bogged down on the main fronts with regime troops in the east and center of the country.
Gadhafi is the Arab world's longest-ruling, most erratic, most grimly fascinating leader -- presiding for 42 years over this North African desert nation with vast oil reserves and just 6 million people. For years, he was an international pariah blamed for the 1988 bombing of a Pan Am jumbo jet over Lockerbie, Scotland, that killed 270 people. After years of denial, Gadhafi's Libya acknowledged responsibility, agreed to pay up to $10 million to relatives of each victim, and the Libyan rule declared he would dismantle his weapons of mass destruction program.
That eased him back into the international community.
But on February 22, days after the uprising against him began, Gadhafi gave a televised speech vowing to hunt down protesters "inch by inch, room by room, home by home, alleyway by alleyway." The speech caused a furor that helped fuel the armed rebellion against him and it has been since mocked in songs and spoofs across the Arab world.
As the rebel force advanced on Tripoli on Sunday, taking town after town, thousands of jubilant civilians rushed out of their homes to cheer the long convoys of pickup trucks packed with fighters shooting in the air. One man grabbed a rebel flag that had been draped over the hood of a slow-moving car and kissed it, overcome with emotion.
Akram Ammar, 26, fled his hometown of Tripoli in March and on Sunday was among the rebel fighters pouring back in.
"It is a happiness you can't describe but also some fear. It will take us time to clear the entire city. I expect a long time for Libyans to get used to the new system and the new democracy," he said, dressed in camouflage pants and black shirt and sporting the long beard of a conservative Muslim. "But in the end it will be better."
The rebels' leadership council, based in the eastern city of Benghazi, sent out mobile text messages to Tripoli residents, proclaiming, "Long live Free Libya" and urging them to protect public property. Internet service returned to the capital for the first time in six months.
The day's first breakthrough came when hundreds of rebels fought their way into a major symbol of the Gadhafi regime -- the base of the elite 32nd Brigade commanded by Gadhafi's son, Khamis. Fighters said they met little resistance. They were 16 miles from the big prize, Tripoli.
Hundreds of rebels cheered wildly and danced as they took over the compound filled with eucalyptus trees, raising their tricolor from the front gate and tearing down a large billboard of Gadhafi. From a huge warehouse, they loaded their trucks with hundreds of crates of rockets, artillery shells and large-caliber ammunition.
One group started up a tank, drove it out of the gate, crushing the median of the main highway and driving off toward Tripoli.
The rebels also freed more than 300 prisoners from a regime lockup, most of them arrested during the heavy crackdown on the uprising in towns west of Tripoli. The fighters and the prisoners -- many looking weak and dazed and showing scars and bruises from beatings -- embraced and wept with joy.
"We were sitting in our cells when all of a sudden we heard lots of gunfire and people yelling 'God is great.' We didn't know what was happening, and then we saw rebels running in and saying 'We're on your side.' And they let us out," said 23-year-old Majid al-Hodeiri. He said he was captured four months ago by Gadhafi's forces crushing the uprising in his home city of Zawiya. He said he was beaten and tortured while under detention.
From the military base, the convoy sped toward the capital.
Mahmoud al-Ghwei, 20 and unarmed, said he had just came along with a friend for the ride .
"It's a great feeling. For all these years, we wanted freedom and Gadhafi kept it from us. Now we're going to get rid of Gadhafi and get our freedom," he said.
The uprising against Gadhafi broke out in mid-February, and anti-regime protests quickly spread. A brutal regime crackdown quickly transformed the protests into an armed rebellion. Rebels seized Libya's east, setting up an internationally recognized transitional government there, and two pockets in the west, the port city of Misrata and the Nafusa mountain range.
Gadhafi clung to the remaining territory, and for months neither side had been able to break the other.
In early August, however, rebels launched an offensive from the Nafusa Mountains, intending to open a new, western front to break the deadlock. They fought their way down to the Mediterranean coastal plain, backed by NATO airstrikes, and captured the strategic city of Zawiya.
Rebel fighters who spoke to relatives in Tripoli by phone said hundreds rushed into the streets in anti-regime protests in several neighborhoods on Sunday.
"We received weapons by sea from Benghazi. They sent us weapons in boats," said Ibrahim Turki, a rebel in the Tripoli neighborhood of Tajoura, which saw heavy fighting the past two days. "Without their weapons, we would not have been able to stand in the face of the mighty power of Gadhafi forces."
Thousands celebrated in the streets of Benghazi, the rebels' de facto capital hundreds of miles to the east. Firing guns into the air and shooting fireworks, they cheered and waved the rebel tricolor flags, dancing and singing in the city's main square.
When rebels moved in, the regime unit guarding the capital, known as the Mohammed Megrayef battalion, surrendered and its commander ordered its troops to put down their arms. Al-Baja, the rebel official, said that the commander, Barani Eshkal, had secretly defected earlier to the rebels, embittered by the 1986 execution of his brother, who had joined a coup attempt against Gadhafi.
Eshkal also pointed out to the rebels the hiding place of Gadhafi's son Seif al-Islam in a hotel, al-Baja said. Rebel chief Mustafa Abdel-Jalil in Benghazi confirmed to the AP that the rebels captured Seif but refused to give details.
In the Netherlands, the prosecutor at the International Criminal Court, Luis Moreno-Ocampo, said his office would talk to the rebels on Monday about Seif al-Islam's transfer for trial. "It is time for justice, not revenge," Moreno-Ocampo told the AP.
Seif al-Islam, his father and Libya's intelligence chief were indicted earlier this year for allegedly ordering, planning and participating in illegal attacks on civilians in the early days of the violent crackdown on anti-regime protesters.
Another son, Mohammed, was under house arrest. Mohammed, who is in charge of Libyan telecommunications, appeared on the Arabic satellite channel Al-Jazeera, saying his house was surrounded by armed rebels.
"They have guaranteed my safety. I have always wanted good for all Libyans and was always on the side of God," he said. Close to the end of the interview, there was the sound of heavy gunfire and Mohammed said rebels had entered his house before the phone line cut off.
Hadeel Al-Shalchi in Cairo contributed to this report.