Leading South African opposition politician Julius Malema, 45, has been sentenced to five years after being found guilty of the illegal possession of a gun and firing it in public.

However, Magistrate Twanet Olivier allowed the leader of the Economic Freedom Fighters and MP to appeal against the sentencing, meaning that he was not immediately taken to prison.

Earlier, standing in court in a dark suit and red tie, Malema showed little emotion as Olivier read out the sentence even though his political future was at stake.

Last year, he was convicted of five offences, including the unlawful possession of a firearm, discharging it in public and reckless endangerment.

If his sentence is upheld, Malema would be disqualified from being an MP for five years. However, political analyst Sandile Swana told the BBC that the appeals process was likely to take several years so the EFF leader would be able to pursue his political career in the meantime.

The charges related to an incident in 2018 when a video emerged showing Malema firing a semi-automatic rifle in the air during his party's fifth anniversary celebrations held in the country's Eastern Cape province.

During the trial in KuGompo City, which is the new name for East London, Malema told the court that he had fired the shots in celebration.

But during her sentencing ruling Olivier said it wasn't... an impulsive act. It was the event of the evening, as reported by the AFP news agency.

She added that while his political standing had no bearing on her findings, he was someone who had a large following in South Africa and should account for his actions.

Addressing some of those followers outside court, Malema made a series of unsubstantiated allegations against Olivier and claimed that the conviction and sentencing were part of a conspiracy against him.

Malema has a long reputation as an outspoken, charismatic and radical left-wing politician and boasts a loyal band of supporters. Hundreds came out to back him outside the court, chanting revolutionary songs.

When news came through that he would be allowed to appeal, they started calling out in the Xhosa language sigoduka naye, which translates as we are leaving with him today.

Malema was once the leader of the youth wing of the governing African National Congress. He later founded the EFF, promoting policies that include the seizure of white-owned land and advocating for wealth transfer to the black majority.

His statements reflect a deep-rooted political tension in South Africa and have drawn widespread attention, including from international leaders.