The Syrian colonel is still astounded. He was directing operations from the second floor of building when he heard gunfire -- rebels had penetrated his headquarters via an underground tunnel.

"One floor closer and I wouldn't be here to describe the attack," he said.

The rebels killed 12 soldiers on the ground and first floors of the building in eastern Damascus before being beaten back by army fire.

Troops discovered the tunnels that had been used to penetrate the building stretched 320 metres (350 yards) between the districts of Qabun and Jubar, two rebel areas of the Syrian capital.

"It was two metres (6.5 feet) high and three metres (10 feet) across. Thanks to the city's electricity supply, it was lit and had ventilation systems. The tunnel was reinforced with metal pillars," says a journalist who toured the tunnel.

"This is a war of moles against hornets," says a businessman in Damascus in characterising the tactics of Syria's rebel and regime in the battle for the country.

The rebels are the moles, digging underground to create tunnels through which they transport weapons, move fighters and prepare explosives away from the fighter jets and helicopters of the army, which buzz overhead.

In Khaldiyeh, a rebel-held district of the city of Homs that fell to the regime last week, a lieutenant-general who gave his name only as Ali describes another narrow escape from an attack.

"In taking the district, we discovered a tunnel that ended almost directly under our headquarters. If we'd arrived 10 days later, our fate would have been sealed," he said.

"We were in one building and our opponents were in another. They were building their tunnel and I heard the noise of their machine in action," he added.

"They were preparing to detonate an enormous explosive charge underneath us, just like they did in Qusayr," the officer said, referring to a town in Homs province recaptured by regime forces in June.

Rebel forces used the same tactic to destroy the regime-held general hospital in Qusayr on September 3 last year.

A video showed opposition fighters descending into a 200-metre long tunnel to place the explosives underneath the building.

Another video, from March 19, shows armed men firing and throwing explosive devices at a building in the Palestinian Yarmouk camp in Damascus, before disappearing into a tunnel, its entrance covered with blankets.

A Western military expert says Syrian regime ally Hezbollah, the Lebanese Shiite movement which made extensive use of a network of tunnels during its 2006 war with Israel, has been charged with flushing rebels out of their underground hideouts.

Soldiers and rebels say the tunnels are sometimes dug by hand, but more often by mechanical drills.

"They are small machines fitted with two drills that can dig a few metres a day," one Syrian army officer says.

"Then they have to reinforce the tunnels, and for that they use hostages, promising to release them afterwards," he adds.

Rebel fighters reject that allegation.

"That's not true. It's our men who are digging the tunnels," says Ahmad al-Khatib, from the Syrian Revolution General Commission, a network of opposition activists on the ground.

"And if one group has made prisoners work on the tunnels, that doesn't mean it's a generalised trend."

Khatib says the tunnels have been key for the rebels, adding that some extend for around 700 metres, including in the Adra region, north-east of Damascus.

"Tunnels have been very useful for us. Thanks to the tunnels, we are able to get past the snipers and go anywhere we want, however far away it is," he told AFP.

"But not all tunnels are linked to each other, and not all areas have tunnels. The areas where there are most tunnels are Homs and Damascus provinces."

Syria's security services allege that Palestinian militant group Hamas, which fell out with the Syrian regime over its response to the uprising, has helped train rebels in the art of digging tunnels.

Hamas regularly tunnels under the borders of the Gaza Strip, into neighbouring Egypt and Israel.

But Khatib rejects the allegations with a laugh.

"So just because I eat noodles does that make me Chinese?" he said.

"Necessity is the mother of invention."