The American entertainer commonly known as Mos Def has 14 days to leave South Africa after he was arrested for violating local immigration laws while trying to leave the country, a government spokesman said Friday.

The rapper and actor, who now goes by the name Yasiin Bey, appeared in a South African court after he was arrested at Cape Town International airport on Thursday, said Department of Home Affairs spokesman Mayihlome Tshwete.

Mos Def produced an unrecognized "world passport" when he tried to leave the country, Tshwete said.

Entertainer overstayed visitor's permit: official

The 42-year-old entertainer entered the country on an American passport in 2013 and overstayed his visitor's permit by 2014, the spokesman said.

A court order to leave the country means the rapper is banned from South Africa for five years, but may appeal to officials for leniency, Tshwete said. Mos Def appeared alongside family members who were also in the country without a permit, the spokesman said.

The New York rapper has lived in Cape Town since May 2013, according to a South African newspaper, the Mail and Guardian.

Mos Def, born Dante Smith, starred in films such as The Hitchhiker's Guide To The GalaxyThe Italian Job and Life of Crime.