Libya's endgame appears to be at hand, bringing to a climax an uprising against Muammar Qaddafi that just weeks ago appeared to be stalled by inexperience, disunity, and a lack of resources.

For months, Libya has been stalemated as rebels have surged forward, only to be pushed back by Qaddafi loyalists. But aided by NATO airstrikes and better organization, rebels have been steadily building momentum.

On Sunday, rebel groups fighting in the west of Libya linked up with armed protesters inside Tripoli and seized Green Square. They insist it has been renamed "Martyr's Square," and a street party was under way there, according to Sky News. CNN reported that at 4:30 am local time that any celebrations were over, and rebel troops controlled the square.

While Libyan leader Muammar Qaddafi's whereabouts are unknown, rebels have reportedly captured at least some of his sons. One of his eldest sons, Mohammed Qaddafi, was giving an interview to Al Jazeera at about 8:30 p.m. Eastern time saying he was in rebel custody when gunfire broke out in his home and the line was abruptly cut off.

While there are bound to be Qaddafi loyalists still about, it's hard to imagine a scenario where Qaddafi remains in power.

[ Video is no longer available. ]

Tripoli all but cut off

As of Friday, the campaign to oust Qaddafi had moved into its final stages.

With Tripoli cut off from the western smuggling routes and from Qaddafi's other major stronghold of Sirte to the east, the rebellion was in prime position to starve his war machine. On Aug. 15 his deputy security chief, Nasser al-Mabrouk Abdullah, fled with his family to Cairo, the latest in a long line of defections since the uprising began Feb. 17.

"It was a question of somebody getting on the ground and organizing the rebels and training the rebels a little bit and that's been going on steadily. There have been some European people doing that," said Col. Pat Lang (ret.), the former head of the Middle East desk at the Defense Intelligence Agency in Washington.

"The result is inevitable: The capital begins to starve, the people will begin to turn against him, en masse," he predicted in an interview before the weekend. "The handwriting is really on the wall."

How rebel momentum grew

While critics of US and NATO assistance to the rebellion have sought to brand the conflict as a quagmire, events this month paint a picture of Qaddafi's writ being pushed back into narrower and narrower spaces.

Col. Roland Lavoie, a NATO spokesmen, told reporters recently that "anti-Qaddafi fighters are now assuming control of the key approaches to Tripoli ... these advances are the most significant anti-Qaddafi territorial gain we have seen in months."

The rebels' push into the western Nafusah Mountains and their success in breaking Qaddafi's siege on the port city of Misurata were key to recent gains. The victory in Misurata cut off Qaddafi's line to Sirte and opened up a new front just east of Tripoli.

Last week, rebels seized and held Zawiyah, on the coast road west to the Tunisian border, and Gharyan, along the southern interior route out of the western half of Libya.

After being routed, Qaddafi forces reportedly abandoned their uniforms and attempted to blend into the civilian population. Video footage showed jubilant rebels outside Zawiyah's refinery, the only one in western Libya and a major source of Qaddafi's fuel supplies.

As of Friday, the only connection between Tripoli and the rest of the country ran through the desert to Bani Walid, southeast of the capital. Rebel spokesmen said they would soon threaten that, too.

Man hunt for Qaddafi?

Though a Qaddafi retaliation was still possible at that point, the tanks and mobile rocket launchers he used with great effect at the start of the war have been either destroyed or immobilized by NATO strikes. Moving whatever reserves he has as the battle for Libya spreads out had become almost impossible.

All that created an arc of peril for Qaddafi stretching from Zawiyah to Gharyan to Misurata. He hasn't been seen in public for weeks, and the foreign press contingent under government control in Tripoli had reported dwindling contact with the government.

There were growing signs of desperation from those around Qaddafi as well. On Aug. 18, Prime Minister Baghdad al-Mahmoudi told reporters that while government forces remain "powerful," a negotiated settlement with the rebels would be the best end to the conflict. "We're able to continue to fight, but from the very beginning we chose peace."

That's a far cry from the previous bellicose statements of Qaddafi and his powerful son Saif al-Islam, who described the rebels as "rats" and "cockroaches" in service of foreign powers who would all be hunted down and put to death.

Whatever slim hope Qaddafi had of hanging on has vanished. It's hard to imagine him staying free for long if the rebels consolidate control of Tripoli – if he's even in Tripoli. If he left Tripoli at some point, a man hunt could be on.

Rebels reject negotiating a deal

Rebel leaders, meanwhile, have dismissed the chances of a negotiated deal. Mustafa Abdel Jalil, head of the rebels' Transitional National Council in Benghazi, told the prominent al-Sharq al-Awsat newspaper that he expects Qaddafi will seek to turn the battle for Tripoli into a "bloodbath."

"Qaddafi will not go quietly; he will go amid a catastrophe that will touch him and his family," he said.

Lang, who supported the NATO intervention in Libya but criticizes the Obama administration for its "desultory" approach to pursuing Qaddafi, says the international community should be ready to help Libya get oil production running again after the regime falls, but otherwise advises limited foreign involvement in what comes next.

"I don't think you need to be very engaged. The Libyans who are running the show on the rebel side are pretty sophisticated people. They don't seem to be dominated by Islamists ... our role [is] just [to] be sort of a benevolent [overseer]," he says.

While the end for Qaddafi, whose mercurial rule stretches back to 1969, when the then-young officer seized control of the country in a coup, has certainly drawn nearer, the means and timing of his departure remain open questions. If key aides turn on him and his family, it could come soon.

If the core of the regime stays loyal, he could hold on to Tripoli for some time yet. But it's hard to imagine a scenario where he wriggles off the hook. Were he a chess master, he'd be turning over his king.