In August 2009, an exhibition titled Innovative Women opened in Johannesburg, aiming to showcase the work of the city’s young black female artists. The launch was attended by Lulu Xingwana, minister for arts and culture at the time, who had been invited to officially open the show. But instead of giving a speech, Xingwana stormed out of the gallery after seeing images by the photographer Zanele Muholi that depicted naked women in close embrace. Muholi’s work, said the minister, was immoral, offensive and ran contrary to “social cohesion and nation-building”. South Africa has one of the most progressive constitutions in the world, with discrimination on the basis of sexuality barred by law. Yet censorious attitudes such as Xingwana’s towards homosexuality are widespread. Almost three-quarters of the population believe same-sex sexual activity is morally wrong, according to a 2016 survey. Similarly intolerant views are commonplace across Africa. Homosexuality is outlawed in 32 of the continent’s 54 nations. It is punishable by life imprisonment in Uganda, Tanzania and Sierra Leone. In Sudan, southern Somalia, Somaliland, Mauritania and northern Nigeria, the penalty is death. Against that backdrop the work of a photographer such as Muholi takes on a dual role, both representing individual artistic expression and operating as a form of political activism; a means to positively assert LGBTQ+ identity in straitened circumstances.

Ama and Shana at lunch by Eric Gyamfi, 2016

Gay relationships are illegal in Ghana, where photographer Gyamfi was born, but the tender, intimate images in the series Just Like Us, where Gyamfi documents life in the country’s queer communities, do not dwell on the sexuality of his subjects but emphasise their ordinariness.

As well as serving to resist oppression, Muholi’s imagery raises a larger question: how do you depict the reality of your life when your very existence is subject to denial or attack? The Ghanaian photographer Eric Gyamfi spent a year documenting queer individuals and communities in his series Just Like Us. Same-sex sexual activity is illegal in Ghana, but you wouldn’t know it from his pictures. Shot in gorgeously textured black and white, the photographs are an intimate evocation of everyday life, titled with studied plainness: Ama and Shana at lunch; Kwasi at Kokrobite beach; Atsu during dance; Kwasi in bed. When queerness is regarded as the opposite of normality, the answer, suggests Gyamfi, is to insist on the very ordinariness of the people being documented and in so doing declare them as individually complex as everyone else. “People are queer but people are also other things,” he says. “People who do not understand queerness have a singular notion of what queer people are supposed to be or supposed to look like. So what I came in to do was to show people that queer people are people first and that they cut across all categories of humanness. There is no singular way of showing who a queer person is, I feel. They can be anything or anybody.”

Afrikan Boy Sittin’ by Hassan Hajjaj, 2013

With its explosion of colours and distinctive handmade frame, this image typifies the powerful and assertive nature of the Morocco-born photographer’s work. Hajjaj’s portraits confront prejudices about culture and identity head on.

Gyamfi’s work both helps to normalise queerness, and throws into question the assumption that African societies are irredeemably homophobic. Notwithstanding the prevalence of anti-LGBTQ+ laws across the continent, his photographs illustrate the fact that queer lives do not exist outside the Ghanaian mainstream, but are an everyday aspect of society. This is also evident in the work of Sabelo Mlangeni. Narratives of queer community formation are mostly set in an urban context, where the anonymity and bustle of city life allows individuals to establish an identity and lifestyle on their own terms, unencumbered by ties of tradition or family. Mlangeni’s photographs tell a different tale. His Country Girls series focuses on gay men in remote, rural South African towns that are traditionally hostile to people who identify as LGBTQ+.

Vintage by Sabelo Mlangeni, 2009

The South African photographer, who works mainly in black and white, documents queer life in the townships of Mpumalanga province in his Country Girls series. Homophobic violence is routine in the towns he visits, yet his work creates scenes of aspirational normality.

We might, then, expect Country Girls to highlight a distinction between the conservative countryside and the cosmopolitan city, with Mlangeni’s subjects adrift in the former and yearning for the latter; in fact, his photographs depict rural communities of gay men living lives of friendship, play and love. The scholar Graeme Reid notes that in such settings, “gay people are regarded ambiguously”. Although perceived by some as “un-African”, they still maintain a place in rural society as the stylish, cosmopolitan outliers, “bringing the very latest fashion styles to the countryside. To be fashionable may be frivolous, modern and, by implication, untraditional, but gay people also embody a set of aspirations, a desire for the new.” Reid continues: “Modernity is at once threatening and desirable, and to the extent that gay people occupy this symbolic space, they are both celebrated and despised.”

Bhekezakhe, Parktown by Zanele Muholi, 2016

The self-portrait is part of a project entitled Somnyama Ngonyama (Hail, the Dark Lioness), in which the South African artist uses direct, psychologically charged images to confront the politics of race and representation.

Other photographers of African origin woring today look outside specific issues of sexuality and explore cultural identity more broadly. Hassan Hajjaj’s photographs, which are shot in the streets and squares of Marrakech, show men and women desporting before the camera like fashion models, gleefully surmounting western cliches of Arab and north African comportment and identity. In work by Athi-Patra Ruga, identities swirl and change; the central figure in his dreamlike tableau Night of the Long Knives seems to exist beyond binaries of male and female, black and white, straight and queer. Likewise, in the work of Ruth Ossai, Jodi Bieber and Phumzile Khanyile, notions of masculinity, body image and the female form are challenged and re-examined. In the process, gender is revealed as complex, fluid and performative; a beginning, not an endpoint, in determining who we are.

Kingsley Ossai, Nsukka, Enugu state, Nigeria by Ruth Ossai, 2017

Part of a series in which the British-Nigerian artist trains the lens on people from her local community, the image challenges ideas about gender, masculinity and what it means to be a man. Ossai’s sitters wore clothes that blur the boundaries between menswear and womenswear.

• Africa State of Mind by Ekow Eshun is published by Thames & Hudson (£39.95). To order a copy go to guardianbookshop.com. Free UK p&p over £15