The murder was so brutal it shocked even the hardened detectives who arrived at the scene on the outskirts of Pakistan's capital, Islamabad. Bushra Iftikhar, a 28-year-old housewife, had been stabbed with such force that the knife her assailant used had bent out of shape, and he had continued the attack with a screwdriver.

The killer? Her husband, Sami Ullah.

The couple had four children already, and at the time of her death Bushra Iftikhar was pregnant with their fifth. Why exactly her husband killed her remains unclear. He claimed in court to have been suffering a mental breakdown and to have no recollection of the incident. Her family says he accused her of wanting to convert to another religious sect.

But what does seem clear is that Sami Ullah was a violent man. He had previously been accused of the attempted murder of a neighbour, and of being part of a violent argument at a restaurant.

Police believe he should have been in prison, but instead he didn't even face a proper trial.

According to Bushra Iftikhar's brother, Sami Ullah's family were influential in the local area and had paid money to the victims of those earlier cases.

"In the old cases, he gave money and quickly got out of prison," Mohammad Zakaria bluntly told the BBC.

Under Pakistani law, victims or their families have the right to forgive suspects in a number of serious crimes, including most instances of murder. All they have to do is state in court that they forgive a suspect "in the name of God". In reality, legal observers agree that the primary motive for that "forgiveness" is normally financial, and the informal payment of money to victims is not illegal.

Image caption Mohammad Zakaria believes his brother-in-law became more violent after the first incidents

The provisions allowing crimes of bodily harm to be "settled" or "forgiven" were introduced in the 1990s as part of a set of Islamic-inspired legal reforms.

Supporters of the system say it helps reduce pressure on Pakistan's already overburdened and delay-ridden court system, and reduces the likelihood of feuds developing. But according to one study, the murder conviction rate in the country dropped from 29% in 1990, before the laws were introduced, to just 12% in 2000.

Critics argue the law can give repeat offenders a sense of impunity, and is a tool for the more powerful to evade justice. Bushra Iftikhar's brother believes the fact her killer was never punished in any of his previous cases only made him grow more violent.

"He became arrogant. He thought: 'I did this, and nothing happened. Now I'm free and the law can't touch me.'"

Sami Ullah's family admit the previous cases had ended in what are often termed "compromises", but insist they had agreed them to avoid a drawn-out legal process, not because Sami Ullah was guilty. Sami Ullah is currently appealing against a death sentence after being convicted of murder.

Image copyright AFP Image caption Many cases never even make it to court (pictured: the Supreme Court in Islamabad)

Ashtar Ausaf Ali, who served as attorney general under the previous government, put forward plans to reform the laws in 2015 whilst still retaining the element of forgiveness.

"A person has the right to forgive," he told the BBC from his office in the city of Lahore, but he added that crime wasn't just a matter for an individual, but for society.

His idea was to introduce mandatory minimum sentences, so that "people would know that they cannot put a price tag on a crime".

Despite being supported by some clerics, Mr Ali's proposals were blocked by a number of Islamist politicians. At the moment, there seems little prospect of them being resurrected.

Undermining the system

The current law is a source of frustration at times for both police officers and criminal prosecutors. Courts do have the right to reject settlements if they believe they are coerced, but most observers agree that due to the number of cases in the court system, they rarely investigate thoroughly.

Meanwhile, one detective told me he had come across dozens of examples of offenders reaching a settlement with their alleged victims only to go on to reoffend. He said the police would spend time and resources investigating a crime only for the case to end abruptly.

Then there are other times, when the police themselves can be the beneficiaries of such "settlements".

Image copyright Handout Image caption Salahuddin Ayubi died after being arrested

In August, CCTV images of a thief sticking his tongue out at the camera as he stole a bank card from a cash machine in the central Pakistani city of Faisalabad went viral on social media.

But the case took a grim turn as shortly after Salahuddin Ayubi was arrested by police, he died in custody.

The compromise

Suspicions mounted after another video emerged of Salahuddin Ayubi, who apparently initially pretended to police that he was deaf and mute, writhing in pain as a policeman twisted his arms behind his back while another interrogated him.

Salahuddin's father, Muhammad Afzal, initially pressed for justice for his son, who is believed to have suffered from a mental illness. However, a month later, he announced he was forgiving the policemen accused of killing him "in the name of God".

The "settlement" or "compromise" in that case is understood to have consisted of an agreement the authorities would build a new 8km (five-mile) road in the family's village, as well as a new gas pipeline, not to mention the payment of an undisclosed sum of money.

Salahuddin's father seemed content with the deal, which was brokered by a radical cleric with links to the intelligence services. But others, who don't have powerful backers or the weight of public pressure behind them, often end up feeling as if they have no choice but to agree with what is being offered to them.

In a village outside Lahore, I met the family of another man who died in police custody. He had been detained after wrongly being accused of murder.

The BBC is not revealing the family's names in order to protect them from repercussions, but they say a mixture of coercion and money led them to drop the case against the police officers they hold responsible for his death.

"We haven't forgiven them in our hearts," the victim's brother told me. "We never will, but we were helpless."

He said a steady stream of local politicians and influential figures had arrived on his doorstep when they began to fight for justice.

"They would say: 'Do a deal. If you don't, you won't be able to do anything anyway. Maybe they'll go to jail for six months or a year, after that they'll be freed and can make all sorts of trouble for you.'"

The family are poor and were offered enough money to buy a house, something they would have struggled ever to do otherwise. They accepted, but the mother remained distraught at the bargain she felt forced to make.

"I wish to God that we were still living in a rented house, and my son was still alive," she said. "They took my son and gave me money for a house, what kind of deal is that?"

Illustration by Nick Galvin