Seven men have been jailed for six months in Senegal, after they were found guilty of homosexuality last week the BBC says.

A court in Dakar heard that police allegedly caught the men having sex during a raid. Homosexuality is illegal in Senegal and is punishable by up to five years in jail and fines of up to $2,500.

According to Article 319 of the Senegalese penal code: “Whoever will have committed an improper or unnatural act with a person of the same sex will be punished by imprisonment of between one and five years and by a fine”.

During a recent trip to Kenya, US President Barack Obama spoke out in support of gay rights in Kenya, a position which raised the ire of Kenyans but welcomed by the LGBT community. However, during his visit to Senegal in 2013, Obama also supported gay rights but the Senegalese president Macky Sall said although the country is “very tolerant” it was “not ready to decriminalise homosexuality”.

Senegal has previously prosecuted homosexual acts. Five lesbians were charged under the country’s anti-gay law and last month journalist Tamsir Jupiter Ndiaye was sentenced to six months in prison for acts of homosexuality, which carries jail terms of up to five years.

Homosexuality is a criminal offence in more than two-thirds of African countries despite calls from regional and global human rights lobby groups to respect diversity and protect all members of society regardless of their sexual orientation and gender identity.