(CNN) Tanzania's Supreme Court of Appeal on Wednesday upheld an earlier ruling banning parents from marrying off girls as young as 15.

A high court ruling in 2016 had declared " unconstitutional" sections of Tanzania's marriage act that allowed the practice. It also directed the government to raise the legal age of marriage to 18 years within a year.

That judgment followed a legal challenge by children's rights activists, who argued that the existing law had pushed many girls into underage marriages.

But Tanzania's attorney general launched an appeal -- one of its claims was that child marriage could protect unmarried girls who get pregnant.

The Supreme Court of Appeal dismissed the attorney general's appeal on Wednesday and asked Tanzania's government to respect the previous ruling, according to court documents seen by CNN.

Read More