A South African court convicted and jailed twin brothers for terrorism on Monday over plans to attack the US embassy in Pretoria and join the Islamic State group, local media reported.

Tony-Lee Thulsie and Brandon-Lee Thulsie, both 28, were arrested in South Africa in July 2016 and have been held in custody since.

The South African brothers pleaded guilty earlier Monday as part of a plea bargain with the prosecution, according to local media.

Hours later the Johannesburg High Court slapped Tony-Lee with an 11-year jail term while his brother Brandon-Lee was sentenced to eight years.

Both pleaded guilty to planning to travel to Syria to join IS, the media reports said.

Tony-Lee also admitted to planning a terrorist attack in South Africa, they added.

Prosecutors said attacks also had been planned against US, British, Russian or French diplomats in Pretoria as well as Jewish institutions.

The United States added the pair to its terror blacklist in 2017.

The arrests of the brothers in 2016 were the first in South Africa relating to alleged IS membership.

South Africa has so far been spared the jihadist attacks that have struck several other countries on the continent, including its eastern neighbour Mozambique.