* Air strikes target Gaddafi's ability to suppress revolt
* Dissent bubbling in capital but not yet at boiling point
* NATO loses hope eastern rebels can advance on capital
By Christian Lowe
ALGIERS, June 21 (Reuters) - NATO is trying to lay the groundwork for an armed uprising inside the Libyan capital to oust Muammar Gaddafi because it has lost hope that rebels elsewhere in the country can advance on Tripoli any time soon.
The pattern of NATO air strikes on Tripoli indicates that the alliance is trying to reduce Gaddafi's ability to defend himself at the moment when his opponents in the city, who for the time being are underground, decide to rise up.
Geoff Porter, of North Africa Risk Consulting, said NATO's true objective was now becoming clear.
"The official NATO policy is to protect civilians from Gaddafi's troops. The unstated goal is to create conditions in Tripoli whereby the local population can achieve 'military breakout' and topple Gaddafi," he said.
It is a high-risk strategy, but one the alliance has been forced into because, three months into a military campaign that most of its supporters thought would take only a few weeks, it has no other real options.
Rebels on three fronts outside the capital have been unable to make significant advances, NATO bombing and defections have not caused Gaddafi's rule to implode and Western powers will not do the one thing that would end the conflict: send in troops.
"I think there is ... a realisation that the rebels don't really have a chance of breaking out from the east, making their way to Tripoli," said Shashank Joshi of the Royal United Services Institute, a London think-tank.
"It will rely on some sort of urban uprising within the city itself."
"At some point he (Gaddafi) will run out of the resources necessary to provide internal security in Tripoli itself, and he will be over-stretched, and when that occurs ... I think you will see many armed groups rise up in Tripoli," said Joshi.
Creating the conditions for this uprising appears to be the logic behind some of the targets in Tripoli that NATO planners have been selecting.
Typhoon jets flown by Britain's air force at the end of May fired weapons to destroy the guard towers along the walls of Gaddafi's Bab al-Aziziyah compound in Tripoli, the British military said.
Those guard towers would be used to defend the compound from any attack by resistance fighters.
Other attacks fit the same pattern: targeting facilities and institutions Gaddafi is likely to rely on to put down a rebellion in Tripoli.
Earlier this month, NATO forces said they attacked Gaddafi's secret police headquarters in Tripoli, and the headquarters of the domestic intelligence service.
In May, an air strike hit what the British military called a base for the Executive Protection Forces, which it said provided the bodyguard for Gaddafi's inner circle.
An air strike this week on the town of Surman, 70 km (45 miles) west of Tripoli, may have been planned in the same context. Libyan officials said the attack killed 19 people, including relatives of Khouildi Hamidi, whose daughter is married to one of Gaddafi's sons.
Hamidi himself survived, but was the likely target. He has been closely involved in efforts to stamp out the revolt against Gaddafi's rule. "He was very much there" during the crackdown, said Ashour Shamis, a British-based Libyan opposition activist.
For Western governments, it is a gamble to count on an underground opposition movement they do not know and cannot see to unseat Gaddafi.
The problem is that the weakness of the insurgents outside Tripoli leaves NATO powers with no viable alternative.
The rebel National Transitional Council added to its growing list of diplomatic allies on Wednesday when resource-hungry China, possibly eyeing oil deals once the conflict is over, said it saw the council as an "important dialogue partner."
In military terms, the insurgents' outlook is less rosy.
In the eastern third of Libya, where the rebels have their main stronghold, they have been trying for weeks to break through pro-Gaddafi defences and reach the oil town of Brega.
Fighters in Misrata, 200 km (125 miles) east of Tripoli, have pushed Gaddafi's forces out of the city but are bogged down in farmland to the west. They take heavy losses every time they push a few hundred metres (yards) towards Tripoli.
Insurgents in the Western Mountains region, southwest of Tripoli, have made the biggest advances. They have thrust pro-Gaddafi forces out of a series of towns and are now within 100 km (65 miles) of the capital.
To get to Tripoli, though, they would have to come down from their mountain plateaux and fight Gaddafi's forces in the desert plains. There, his heavy weapons will give him an advantage.
Given time, the insurgents would probably break through. But time is a commodity NATO does not have.
With each day the conflict drags on, strains within the alliance over the cost, the civilian casualties and the legality of the operation are increasing.
"We are probably getting there (on the military front) but very, very slowly, and probably too slowly for those in NATO who are getting reasonably jittery," said David Hartwell, Middle East and North Africa analyst with IHS Jane's, a defence and security consultancy.
"NATO appears, or part of it appears, to be getting cold feet, or questioning the commitment, and that gives him (Gaddafi) an incentive to stick around and say to himself: 'I can wait this out'," he said.
So far, many of NATO's calculations about what it will take to oust Gaddafi have proved over-optimistic. Will its new strategy of backing a Tripoli uprising prove any different?
It is clear that there is an underground opposition movement inside the Libyan capital.
Activists have held "flash" protests, chanting anti-Gaddafi slogans for a few minutes, then melting away. They have hung the rebel green, black and red flag from bridges, and at night write anti-Gaddafi graffiti on walls.
Their activities go beyond non-violent protest. At night, exchanges of gunfire can be heard in parts of the city. Libyan officials say it is celebratory gunfire. Some residents say it is the security forces clashing with insurgents.
The authorities are sufficiently worried about rebels smuggling weapons into Tripoli that they search vehicles at roadblocks at the entrances to the city.
At the same time, there are signs that the security forces on which Gaddafi relies to control internal dissent -- known to Libyans as the "Katiba" -- are being stretched.
Some media reports say that barely-trained students have been given guns and told to man checkpoints in Tripoli because the regular forces have been sent away to the front lines.
However, the balance of forces in Tripoli remains on Gaddafi's side. He still has forces with sufficient numbers, weapons and loyalty to shoot at anyone trying to revolt.
To change that, analysts say, will take a big rebel victory in the east, the defection of an important security unit in Tripoli, or something else which loosens Gaddafi's grip on power in the city.
As with the other approaches NATO has tried to topple Gaddafi, encouraging an uprising in Tripoli will take what the alliance can least afford: time.
"I think there is dissent in Tripoli, bubbling, really percolating grievances," said Joshi at the Royal United Services Institute. "As for whether it (a revolt) is likely I think yes, but not any time soon."
Editing by Mark John and Mark Heinrich