On special days, after dawn prayers at the mosque, father of two Ameer returns home to put on makeup from the collection he shares with his wife.

Usually, however, he settles for a colourful headscarf of the sort worn by women throughout Nigeria. Ameer also uses the female version of his name, Ameera, preceding it with Hajiya, the honorific for women who have completed the Muslim hajj pilgrimage to Mecca.

Ameera is known as a yan daudu, shorthand for "men who act like women" in northern Nigeria's Hausa language. The phrase means "sons of Daudu," a fun-loving, gambling spirit worshipped in the Muslim Bori practice, whose trance and dancing rituals are traditionally associated with marginalised poor women, sex workers and disabled people.

For more than a century, hundreds of yan daudu were tolerated as part of an unremarkable but fringe subculture in the Muslim north, famed for their playful use of language, sometimes even accompanying politicians during election campaigns.

In this spirit, Ameera's parents were accepting. "My parents realised all the things men like, I didn't like. I didn't like farming. I wanted to cook and sell things like women. Most of all, I loved braiding hair – I can do yours very nicely if you want," said Ameera, with a dimpled smile and shrug of delicate, bird-like shoulders.

"They bought me a doll and let me spend hours braiding its hair," he said, his soft voice almost drowned out by the screech of rickshaws and shouting tradesmen in a bustling, overcrowded satellite town outside the Nigerian capital, Abuja.

But now, with a religious revival sweeping Africa's most populous country, the yan daudu are increasingly being persecuted. As Nigeria edges closer to passing a bill outlawing same-sex marriage and targeting groups who support sexual minorities, many fear they will be driven underground.

"I don't mind it when my friends call me yan daudu, but these days it sounds ugly [abusive] in other people's mouths," Ameera said.

On the plastic-covered walls hung miniature portraits of yan daudu colleagues, taken during a special trip to a studio so long ago the edges have yellowed. Many had previously lived in Kano, the north's main city and a former Islamic sultanate that has long been a regional hub bringing together sexual minorities from across Nigeria and its desert neighbours.

"People were more tolerant then. Now people are more religious, we've had to change our outlook too. We can't go out wearing brassieres and makeup any more," said Salihu (Hajiya Sara), a yan daudu from neighbouring Chad, dressed in a sober black kaftan and so painfully shy he can barely make eye contact. He fled Kano in 2000, when Nigeria underwent one of its periodic "morality campaigns" and 12 northern states adopted sharia law.

"It hurts my heart that people say, 'May Allah reform you,'" he said, washing his feet in preparation for prayers.

As he hurried to the muezzin's dusk call floating over the lamp-lit stalls, he added: "All judgment belongs to Allah, so if we are different it is because Allah made us different. All these clergymen condemning us should be careful though, because Allah can make one of their own children like us."

Yet there remain some signs of acceptance. Dreadlocked mechanic Rodney Musa, repairing a motorbike in a patch of oil-stained dust nearby, isn't bothered by his neighbours. "They've been here for the past 10 years – as far as I'm concerned we're all just trying to earn a living," he said.

Overhearing the conversation, a passing shop owner, Naz Nwakesi, reacted with horror. "They're simply homosexuals with bad characters. They should try to reform themselves," he said.

Amarchi, braiding hair at an open-air salon wedged between the Jesus is Trading hardware shop and Godz Power Barbing salon, said the yan daudu were embarrassing to women. "They should speak to God and ask God to make them women," she added, before quoting a Bible verse that forbids cross-dressing.

At Ameera's food shack, where around a dozen yan daudu find refuge working in an occupation normally reserved for women, these criticisms hurt. "That's why my heroes are female prostitutes. There's a kinship between us because they know what it is to be judged," Ameera said. Though many yan daudu are gay, "some of us pretend to be gay just to feel alive – at least we know where gay people fit in the scheme."

Whatever their orientations, few see being yan daudu as at odds with family life. Ameera is preparing to take a second wife while Yahuza, 32, wearing a sparkling red dress and sandals decorated with bright diamante flowers, has three.