The sexual history of alleged victims will be off limits without pre-trial sign-off from a judge, after a law change passed with unanimous support.
Sexual violence complainants won't be shielded from having such details introduced by defence teams but the change will allow them to prepare themselves for such an eventuality, the government says.
Currently, a party that wants to introduce evidence about a complainant's sexual history with a person other than the defendant must apply to the court for permission.
That permission can be sought at any time during the trial. Under the new law, it will need to be before the case is tried, unless a judge rules otherwise.
National MP and Attorney-General Chris Finlayson said the change would give victims time to come to terms with what will be discussed in court.
Labour justice spokeswoman Jacinda Ardern said the balance in the law would be such that evidence of past sexual history would not be allowed.
The case of Sophie Elliot, brutally murdered by former Otago University tutor Clayton Weatherston, showed how distressing it could be to a victim's family to feel their loved one was on trial, and not the accused, Ardern said.
Other changes in the Evidence Amendment Bill include creating a presumption that children under 18 won't give evidence from the witness box.
Instead, evidence will be heard through the video of a police interview, or through closed-circuit television or from behind a screen.
Child witnesses will be automatically entitled to have a support person with them when they give evidence.
While many children who give evidence in criminal cases already do so through alternative means, the Government says applications to do so vary across different regions.
The legislation will also introduce stronger restrictions on access to video records in sexual and violent cases, and to child complainants' evidence in all cases.
The defence will only be able to view such videos on police premises or other places agreed with the police. The defence will also be able to apply to the court for a copy of the video.
Women's rights campaigner Louise Nicholas has told the Herald that prior sexual history should be brought up only if it was absolutely vital evidence.
"But at the end of the day it still comes down to what happened in the past with other relationships. [That] shouldn't have any bearings on an alleged offender's actions."