Wellington (AFP) - A foreign envoy who fled sex charges in Wellington by invoking diplomatic immunity is from Malaysia, New Zealand courts revealed Tuesday after overturning a media gag order.

Both the man's name and home nation had been suppressed after the diplomat allegedly attacked a woman last month then returned to Malaysia after officials in Kuala Lumpur refused a request to waive his diplomatic immunity.

Police allege the man, who can now be named as Muhammad Ismail, was arrested in Wellington after following a 21-year-old woman on the night of May 9 and attacking her in her home.

He was charged with assault with intent to rape and burglary but the case had to be dropped when he invoked diplomatic immunity. He also reportedly refused to submit a DNA sample.

Malaysia has a large diplomatic compound in Brooklyn, the Wellington suburb where the attack allegedly took place. Ismail is listed as staff assistant (defence) on the high commission's official website.

The high commission refused to comment when contacted be AFP but foreign ministry officials in Malaysia were due to address the issue when it briefs the media later Tuesday.

Judge David Collins overturned the suppression order in the High Court in Wellington after a challenge by media organisations, saying Ismail was likely to be named at a press conference in Malaysia anyway.

Before the decision, New Zealand Foreign Minister Murray McCully said he called in the country's top diplomat on Monday to express how seriously Wellington viewed the matter.

He said he made it clear to the senior envoy -- High Commissioner Rosmidah Zahid -- that there would be consequences if no action was taken against the man.

"It will have a bearing on how we deal with the country concerned," McCully told reporters.

Prime Minister John Key expressed similar sentiments on Monday, saying New Zealand preferred immunity was waived so the man could face trial in New Zealand but, failing that, he should be prosecuted in his homeland.

Story continues

"We're going to stay on the case, we're going to do everything that we possibly can to ensure that this person is held to account," Key told reporters.

McCully said it made no sense for New Zealand courts to maintain the suppression order, since the diplomat had returned home.

"I can't see any good public policy reason why you'd want to protect someone from publicity, given that there won't be a trial," he said.

New Zealand and Malaysia signed a bilateral free trade agreement five years ago and two-way trade was more than US$2.5 billion in 2012, according to official data.

Malaysia is New Zealand's eighth largest trading partner, with exports dominated by food and beverages, while imports from Malaysia largely consist of petroleum and electronic goods.