 Mandela was imprisoned by a then predominantly white government of South Africa for a total of 27 years  until the abolition of apartheid in the country.
<meaning-changed>  Mandela was imprisoned by a then predominantly white government of South Africa for a total of 27 years  until the abolition of apartheid in the country.
 Mandela was imprisoned by a then predominantly white government of South Africa for a total of 27 years by a then predominantly white South African government until the abolition of apartheid in the country.