The impoverished relatives of a murdered 16-year-old girl are fighting the wealthy family of an MP in Afghan courts in a case that is testing the progress of efforts to bring members of the country's elite within reach of the law.

The girl, known only as Shakila, was shot dead in 2012 in the house of Wahidi Behishti, a senior official in central Bamiyan province and the son of a civil war-era commander. He is accused of murdering her. Her family also believe she was raped.

The case has ricocheted through provincial courts and the capital, Kabul, alternately sidelined and pursued by judges and prosecutors, as Behishti and his relatives, including a brother who is an MP, have sought to quash it.

An unusually vocal and high-profile series of demonstrations has helped keep the case in the public eye.

Confidence in the slow and corrupt legal system is low across Afghanistan. Most people think the rich can buy verdicts, and women are particularly unlikely to seek or receive justice.

Three people convicted of torturing a child bride were recently freed by an appeal court, fuelling fears that as Nato withdraws from Afghanistan, many of the improvements in women's rights are at risk.

Activists say they are surprised and cautiously encouraged that ordinary Afghans and non-governmental organisations, together with some brave lawyers and judges, seem to have bucked the trend and kept the Shakila prosecution in the courts.

"This case is unusual in the attention it has drawn to violence against women, and the perception many Afghans have that the powerful can murder with impunity," said Heather Barr, Afghanistan researcher at Human Rights Watch. "The protests that happened in relation to this case and a few other recent cases are, hopefully, a sign of the women's rights movement becoming more emboldened and outspoken. The fact that key justice officials refused to participate in covering up this case is also a hopeful sign, though these hopeful signs come against a backdrop of women's rights being increasingly under threat."

Shakila had moved to Bamiyan as a reluctant helper for her pregnant sister, Soraya, whose husband worked as a bodyguard for Behishti. On a cold winter's afternoon in January 2012, after six months of pining for home, she bled to death from a single bullet wound.

Neither of Shakila's relatives witnessed the shooting. Her brother-in-law's AK-47 was the murder weapon but he was in the bazaar buying coal, while Soraya was washing clothes by the river.

Behishti, a member of the Bamiyan provincial council, says the death was suicide and that his political enemies cooked up the charges of murder and allegations of judicial corruption. "It's all my enemies who said I bribed the court," he said. "Shakila committed suicide by firing on herself, I didn't even hear the gunshot … I was in the house but a different room, praying."

However, her family believes otherwise. On that January afternoon, Soraya returned from the riverside to the house to find her dying sister on the floor, and the AK-47 propped a few feet away against the wall, with no blood on it or nearby. There was no sign that Shakila had been moved.

"She wasn't able to speak, because she had been shot in the heart," said her brother Mohammad Alam, a 19-year-old who is leading the family's fight for justice. "She could move her arms and legs a little, but she couldn't walk."

A few minutes after Shakila's death, Behishti and his family took her body to the provincial hospital without calling the police, and no one thought to question the story of suicide, Alam said.

Eventually, the criminal investigation department sent the body for an autopsy, and the coroner found the gunshot trajectory ruled out suicide. "The death of the deceased was forced, based on the properties of the injuries," a translation of the autopsy provided by Human Rights Watch said.

The examination also found that Shakila was not a virgin when she died. A shy, illiterate teenage girl from a conservative village, she was unlikely to have had an affair in a town where she knew almost no one, and her family believe Behishti raped her then killed her because she had threatened to reveal his abuse.

"She was not a social girl, she was very young and very traditional. Maybe Behishti was concerned that she was pregnant," said Zahra Sepehr, director of the Development and Support of Afghan Women and Children Organisation, which has been helping Shakila's family pursue the case.

A prosecutor in Bamiyan first accused Shakila's brother-in-law of the murder, but he had an alibi from his shopping trip and the case was thrown out of court, said Abdul Wadood, executive director of another civil society group, Human Rights and the Eradication of Violence Organisation. Behishti then became the main suspect.

Demonstrations helped force the authorities to take the case back to court, but this time prosecutors said it was suicide, despite the autopsy report.

In court, the judge tried to manipulate an assault rifle into the position Shakila was said to have used to kill herself. When he failed, he ruled that suicide was impossible and sent the case to Kabul for trial.

There, Shakila's family thought they had found a champion when the first government lawyer to take the case told them he thought it called for capital punishment. But the trial went ahead in secret, with just prosecutors, judges and the accused present, and Behishti was declared innocent.

Shakila's family and the activists supporting them asked the public for support, demanding that the attorney general's office appeal against the decision.

An official has promised a new trial, although the family and their supporters have no illusions about their opponents – and only limited optimism about the final outcome.

"The new prosecutor said he is under a lot of pressure, but he is focused on his duty and will not listen," Sepehr said. "Shakila's father has recorded a message saying he will wait to see if he can get justice for his daughter, but if not he will come to parliament with his wife and burn himself."