The Syrian army announced the country's second city Aleppo has been fully recaptured from rebel fighters, the government's biggest victory in the nearly six-year civil war.

The last group of rebels and their families holed up in a small enclave in eastern Aleppo were evacuated on Thursday, under a deal that gives the army and its allies full control of the ancient city after years of fighting.  

"Thanks to the blood of our heroic martyrs, the heroic deeds and sacrifices of our armed forces and the allied forces, and the steadfastness of our people, the General Command of the Army and the Armed Forces announces the return of security and stability to Aleppo," said a military statement read by an army general on state television.

OPINION: Aleppo - The guilt, the resentment, the indifference

The statement said the victory in Aleppo is a "strategic transformation and a turning point in the war on terrorism and a deadly blow to the terrorist project and its supporters".

It is a further incentive, it added, to go on fighting to "eradicate terrorism and restore security and stability to every span of the homeland".

More buses leave Aleppo after delays

It represents a momentous victory for President Bashar al-Assad and a crushing defeat for Syria's opposition.

Western Aleppo erupted in celebratory gunfire seen on Syrian TV, which showed uniformed soldiers and civilians shouting slogans in support of Assad.

The ancient city of Aleppo had been divided into rebel and government parts since 2012.

The announcement came shortly after state television reported that the last convoy carrying rebels and civilians had left eastern Aleppo.    

"The last four buses carrying terrorists and their families arrived in Ramussa," a district south of Aleppo controlled by government forces, the channel said.

Rebel evacuations were set in motion last week after Syria's opposition agreed to surrender its last footholds in eastern Aleppo. Since then, some 35,000 fighters and civilians have been bussed out, according to the United Nations.

Ahmed Qorra Ali, an official with the rebel group Ahrar al-Sham, confirmed: "The last convoy has left the rebel-controlled area."

READ MORE: Four evacuees killed, convoy sent back to east Aleppo

Earlier, the Red Cross said more than 4,000 fighters had left rebel-held areas of the city in the "last stages" of the evacuation.

Rebel forces agreed to withdraw from the bastion after a month-long army offensive that drove them from more than 90 percent of their former territory.

The evacuation agreement was brokered by Russia, which launched air strikes in support of Assad's regime last year, and Turkey, which has supported some rebel groups.

The loss of east Aleppo is the biggest blow to Syria's rebel movement since fighting started in March 2011. More than 310,000 people have been killed since then.

It puts the government in control of the country's five main cities: Aleppo, Homs, Hama, Damascus, and Latakia.     

"The liberation of Aleppo is not only a victory for Syria but also for those who really contribute to the fight against terrorism, notably Russia and Iran," state news agency SANA quoted President Assad as saying before the army announcement on Thursday.

The Syrian government's recapture of Aleppo is a major turning point in the Syrian civil war with potentially powerful political repercussions.

"On the political level, this is a great loss," Yasser al-Youssef of the Nureddin al-Zinki rebel group told AFP news agency. "For the revolution, it is a period of retreat and a difficult turning point."    

Referring to Assad's closest allies, Ali of the Ahrar al-Sham rebel group said: "Aleppo is now under the occupation of Russia and Iran."

Hundreds leave Aleppo as evacuation resumes

Source: News agencies