Pakistan passed long-awaited legislation Thursday closing a loophole that allowed people who killed for "honor" to walk free, three months after a social media star was murdered by her brother, sparking international revulsion.

The legislation, passed unanimously by the National Assembly, mandates life imprisonment for the killer, even if the victim's relatives forgive the murderer.

The assembly also passed a bill boosting the punishments for some rape offences, mandating DNA testing and making the rape of a minor or the disabled punishable by life imprisonment or death.

Women have long fought for their rights in Pakistan, and so-called "honor" killings claim the lives of hundreds each year.

Rape conviction rates are close to zero percent, largely due to the law's reliance on circumstantial evidence and a lack of forensic testing.

Rights groups and politicians have for years called for tougher laws to tackle perpetrators of violence against women in the country.

The gruesome murder of Facebook star Qandeel Baloch in July catapulted the issue into the international spotlight.

"This is a step in the right direction," women's activist and columnist Aisha Sarwari told AFP. "We should take our little wins where we get them and proceed forward and not retreat."

But rights activist Farzana Bari was more cautious, saying the bill still allowed a judge to decide whether a murder qualified as an "honor killing" or not.

The perpetrators of honor killings — in which the victim, normally a woman, is killed by a relative — often walk free because they can seek forgiveness for the crime from another family member.

A 2005 amendment to the law pertaining to honor killings prevented men who kill female relatives pardoning themselves as an "heir" of the victim.

But the punishment was left to a judge's discretion when other relatives of the victim forgive the killer — a loophole which critics say had been exploited.

The amendments passed Thursday and published on the National Assembly website mandate judges sentence someone who kills in the name of "honor" to life imprisonment, even if they have been forgiven, said senior opposition lawmaker Farhatullah Babar.

"Even if the close family members pardon the murderer, the court is bound to send him to jail for 25 years," Babar told AFP.

Filmmaker Sharmeen Obaid-Chinoy won an Oscar earlier this year for a documentary on honor killings that was hailed by Pakistan's Prime Minister Nawaz Sharif, who promised to push through the legislation in February.

But no action was taken, despite a slew of further high-profile killings, until the strangling of Qandeel Baloch.

The death of the social media star, judged by many in the country as infamous for selfies and videos that by Western standards would appear tame, reignited polarizing calls for action after her brother admitted to killing her.

"I am not embarrassed at all over what I did," he told media at a defiant press conference in July. "Whatever was the case, [my sister's behavior] was completely intolerable."

Obaid-Chinoy slammed Baloch's murder as symptomatic of an "epidemic" of violence against women in Pakistan.