It was, says Khaira Arby with some pride, her music that swung the election in favour of Timbuktu’s first female MP. Arby had been asked by the only female candidate, Aziza Mint Mohamed, to perform at a rally on the last day of campaigning in Mali’s national assembly elections of 2013. She had travelled the 560 miles from Bamako to Timbuktu especially, setting up her band in the sandy acres of open ground between the 14th-century adobe-walled Sankoré mosque and the city’s single paved road.

When she reached the city, Arby, a desert blues legend and cousin of the late Ali Farka Touré, discovered Mint Mohamed’s main rival was holding a simultaneous rally a few hundred metres away in the Grand Marché. When “the nightingale of the north” started to sing, however, the unfortunate contender’s audience began to move northwards towards the soulful notes that were drifting out of the Place Sankoré. Mint Mohamed went on to win the election.

It was a sweet victory for Arby and Mint Mohamed, not least because of their opponents’ sexism. In the first stage of the two-round vote, five male candidates, were ranged against Mint Mohamed; in the second round, when she was running against a member of the president’s RPM party, all four of the men who had lost urged their supporters to vote against her.

“They said, no, a woman cannot be MP for Timbuktu,” says Mint Mohamed, a short but forceful presence whose father was one of Timbuktu’s leading imams. “In the madness of the election campaign, the men of the north said a woman MP could not be good for the city. But if politics had been forbidden for us by Islam, my father wouldn’t have let me go into politics. So I said to them, show me the verse in the Qur’an where it says that a woman cannot be MP. They weren’t able to.”

A year after Mint Mohamed was elected, stories of the suffering and humiliation women experienced under jihadi rule in 2012 are beginning to emerge. In late March that year, a rebellion in the north of Mali sparked by the fall of Muammar Gaddafi in Libya swept across the north of the country. On 1 April the rebels captured the remote desert town. So began a nine-month occupation, first by the secular Tuareg separatists of the MNLA, whose fighters wrecked government buildings and stole what they could, then by the jihadi alliance of Ansar Dine (Defenders of the Faith) and al-Qaida in the Islamic Maghbreb (AQIM).

It was an unprecedented situation: instead of merely attempting to destabilise a political structure to pursue global jihad, al-Qaida was now in possession of a famous city that it set about trying to govern. The jihadis imposed their version of sharia law, with catastrophic consequences for the women of the north.

Arby was on tour on the day Timbuktu fell, and friends warned her not to return. The rebels broke into her house and wrecked it. “They came to my house and were trying to find me because I am a musician,” says Arby. “They found all my instruments and took them and they burned them. I thought if I was there maybe they would catch me and do the same thing to me.”

The jihadi ban on music – something that, according to Arby, had never happened in Timbuktu’s long history of invasions – hit women hard because the musical tradition for which the north of Mali is famous has been kept alive by women. “Music is very important to Timbuktu. You can’t have a wedding, or a baptism, or a big meeting of the population here without music. It is something that unifies people, that can pass a message to the people. Since its creation, the people who made music in Timbuktu were the married women. They took up their violins and made their music for their husbands, to make them happy, and for their own pleasure, to sing love songs.”

During the occupation even musical ringtones were forbidden: jihadis, including the al-Qaida governor of Timbuktu, Abdelhamid Abou Zeid, chose the sound of a laughing baby instead for phone alerts. Arby says the occupiers’ interpretation of Islamic texts with regard to music is just wrong. “Music is a big part of Islam. The day the prophet entered Mecca they made music for him, they sang for him. If it was forbidden it would have been forbidden ever since then.”

Other parts of the jihadis’ sharia law were equally painful for women. They appeared obsessed with sex and sexuality: unmarried couples with children were beaten, and every interaction between unrelated men and women was banned. Brothers and sisters, mothers and sons who were found talking in the street were interrogated by the fighters. At checkpoints, gunmen stopped vehicles not for illegal goods or arms, but to check that male and female passengers were not sitting in the same row.

But it was the dress code that caused most grief: women were forced to cover all except their faces. Women with manual jobs found it almost impossible to work in their jihadi-approved gloves.

Stories of women being beaten or jailed for dressing incorrectly are legion in the city. The Islamic police’s “vice squad” set up a women’s jail in the ATM booth of the Malian Solidarity Bank. The booth was no more than three metres by two, yet a dozen women would be held there for days at a time with no access to water or sanitation. People who live nearby remember distressed prisoners wailing all night, and in particular one young woman who had a seizure and cut herself while smashing the glass door of the booth. Even as she bled profusely and people tried to help her, the vice squad’s leader, Hamid Moussa, told her she deserved everything she got and he would let her die in prison.

Other women say they were told to buy jihadi-approrpriate clothing they could not afford from Moussa’s wife.

“They had applied their law, and if you did not obey their law there were sanctions,” says Mint Mohamed. “So when the women refused to wear the burka, they sanctioned them. If the men didn’t wear their trousers short, they were forced them to cut them with scissors. These were their laws and their justice. If you don’t respect their law they put you in jail.”

She continues: “It was a violation of human rights, and it was the women who suffered the most, because in Timbuktu the women go out a lot. They go to the market, they earn money, they run small businesses, they almost run a branch of the economy. And they are already covered, but burkas are not part of our culture. All the women who didn’t wear them got into difficulty. It was truly a humiliation.”

When French and Malian troops liberated Timbuktu on 28 January 2013, the people who had not fled the city came out to welcome them. Almost two years on, long-term peace, the big prize, remains elusive. “The jihadis left with [the French-led] Operation Serval,” says Mint Mohamed. “But now there has been a rebirth of the armed groups. They have come back and it is only the capital of the Timbuktu region that is free. Even there it’s not good, people aren’t able to sleep, every day they say they are about to take Timbuktu, people are coming tomorrow. They are afraid. It’s not good for the mind or the spirit.”

Timbuktu is lucky, she says, because of its name, cultural heritage, saints and women. “Did you know the Sankoré mosque was financed by a woman,” she says. “And Timbuktu was founded by a woman. Today the UN force in Timbuktu is led by a woman. We have had many great women – and that is why Timbuktu has women in authority today.”

Development and education for the population are her priorities, but these are overridden by the need for peace, which she hopes may yet be delivered by talks between the rebels and the government in Algeria, due to restart in the new year. “I am optimistic,” Mint Mohamed says. “As long as people are talking, there is reason to hope.”