The court's ruling in June meant Botswana joined a handful of African countries that have legalised same sex relationships

GABORONE, July 6 (Reuters) - Botswana's government will appeal a high court ruling which decriminalised homosexuality, potentially resuscitating a law that punished gay sex by up to seven years in prison.

The court's ruling in June, which was praised by international organisations and activists, meant Botswana joined a handful of African countries that have legalised same sex relationships.

Attorney General Abraham Keetshabe said in a statement released late on Friday that the high court was mistaken in its conclusion in overturning the colonial-era law.

"I am of the view that the High Court erred in arriving at this conclusion and thus, I have decided to note an appeal with the Court of Appeal," said Keetshabe without giving further details on the grounds for the appeal.

In June, a panel of three judges ruled that sections of the penal code that ban gay sex are unconstitutional as they violate privacy, liberty, and dignity; are discriminatory; and serve no public interest.

The case, which had been brought by a university student, Letsweletse Motshidiemang argued the government should do away with the law in light of a changed society where homosexuality was more widely accepted.

Same-sex relationships are illegal in more than 70 countries worldwide; almost half of them in Africa, where homosexuality is broadly taboo and persecution is rife.

Botswana's ruling came after Kenya's high court upheld its law banning gay sex, keeping same sex relations punishable by 14 years in jail, drawing strong criticism from the United Nations and rights activists.

Previous rulings in Botswana had partially acknowledged the rights of lesbian, gay, bisexual and transgender people in the southern African country, including their right to equal protection before the law.

President Mokgweetsi Masisi also signalled his support for same-sex relations in a speech in December, where he said LGBT citizens deserve to have their rights protected.

Botswana is the latest country in Africa to decriminalise same sex relations, with Amnesty saying it follows Angola in January, Seychelles in June 2016, Mozambique in June 2015 and Sao Tome and Principe, and Lesotho in 2012.

South Africa is the only African nation to have legalised gay marriage. (Reporting by Brian Benza; Editing by Toby Chopra)

Openly is an initiative of the Thomson Reuters Foundation dedicated to impartial coverage of LGBT+ issues from around the world.

Our Standards: The Thomson Reuters Trust Principles.