* Army says it targets Aleppo after lifting prison siege
* TV footage shows soldiers at prison celebrating
* Military gain comes 12 days before presidential election (Recasts with TV footage, army statement)
By Dominic Evans
BEIRUT, May 22 (Reuters) - President Bashar al-Assad's troops broke a year-long rebel siege of Aleppo's main prison on Thursday, cutting a main insurgent supply line and vowing to press on and recapture the whole of Syria's biggest city.
State television showed soldiers inside the prison after they routed al Qaeda and other Islamist forces who had tried several times in recent months to break into the jail and free thousands of prisoners.
The military gain comes 12 days before an election widely expected to deliver a landslide victory - and seven more years in power - for President Bashar al-Assad, whose forces have been cementing his control over the centre of the country.
A military statement said the fighting around the prison, about 5 miles (8 km) north-east of Aleppo, had cut a supply line linking the rebel-dominated rural hinterland with the contested city.
"It represents a heavy blow to these groups that were using the countryside as a base to target Aleppo and its population," the statement said.
The military command was determined to "hit the terrorist groups with an iron fist and restore security and stability to Aleppo city and every inch of the country."
Assad's forces and rebels have been fighting for two years in Aleppo, Syria's commercial hub before the start of its three-year civil war, and the countryside around it.
Television pictures from inside the prison complex showed dozens of bearded and weary soldiers, who had held out against 13 months of rebel siege, standing behind grey sandbags and celebrating the arrival of the relief troops.
They also showed prisoners, men and women, behind bars in long rows of cells.
Rebels, including fighters from al Qaeda's Nusra Front, have tried repeatedly to storm the prison, breaching its outer walls with huge bombs but failing to take full control.
The Syrian Observatory for Human Rights monitoring group said 3,000 inmates were held at Aleppo jail, including Islamists and other political prisoners as well as common criminals.
It said the air force continued to bombard rebels near the prison with barrel bombs on Thursday, a third day of heavy fighting after they launched an offensive on Tuesday to push back the insurgents.
The Britain-based, anti-Assad Observatory, which monitors the violence in Syria through a network of activists and medical and military sources, says more than 162,000 people have been killed in the civil war, which grew out of protests against Assad's rule in March 2011.
Assad's forces, backed by Shi'ite fighters from Iraq and Lebanon's Hezbollah, have pushed back rebels around the capital Damascus and the city of Homs, strengthening his hold over a chain of cities running along Syria's north-south axis.
But rebels have made gains recently near the southern city of Deraa, and control a swathe of territory from rural Aleppo in the north down through the farmlands and oil producing regions to the east. (Editing by Mark Trevelyan)