New Zealand’s prime minister, Jacinda Ardern, fought back tears while offering a heartfelt apology to the family of the murdered Briton Grace Millane, as the man accused of killing the backpacker made his first court appearance.

A visibly emotional Ardern said there was a collective feeling of shame in the South Pacific nation over the fate of Millane, whose body was found on Sunday in dense bushland in western Auckland.

“There is this overwhelming sense of hurt and shame that this has happened in our country, a place that prides itself on our hospitality, on our manaakitanga,” she said, using the Māori word for welcoming others.

“So on behalf of New Zealand, I want to apologise to Grace’s family – your daughter should have been safe here and she wasn’t, and I’m sorry for that.”

Ardern told reporters at her weekly media conference on Monday that New Zealanders were heartbroken for Millane’s family and were feeling her death personally.

Her statement came after a judge acknowledged Millane’s grieving family when the man accused of her murder appeared in court.

Grace Millane was on a year-long world tour after graduating from university. Photograph: Lucie Blackman Trust/PA

The 26-year-old man was taken into custody after police launched a homicide investigation over the weekend. Officers found Millane’s body on Sunday in bush on the western outskirts of the city, about 25km from where she was last seen entering the central CityLife hotel with a man on 1 December, the day before her 22nd birthday.

Appearing in Auckland district court on Monday morning in a blue prison boilersuit, the accused had an attempt to keep his name secret rejected, but an immediate appeal by his lawyer meant he still cannot be publicly identified.

Such restrictions are not uncommon in early court hearings in New Zealand.

During the appearance, Judge Evangelos Thomas addressed members of Millane’s family: “All of us hope that justice for Grace is fair, swift and ultimately brings you some peace. I don’t know what we can say to you at this time – your grief must be desperate,” he said.

Court documents said the accused was a resident at the CityLife on Queen Street in Auckland and was charged with killing the tourist between 1 and 2 December. No occupation was listed.

As the accused was led away from the dock, somebody in the public gallery yelled out “Scumbag!” The man is due back in court on 23 January.

Tributes to Grace Millane are left at a roundabout in Titirangi in Auckland Photograph: Fiona Goodall/Getty Images

Officers have said Millane and the accused had not previously known each other and declined to confirm reports they met through an online dating app.

Millane, from Essex, was on the second leg of a year-long world tour after graduating from university. After visiting Peru, she arrived in New Zealand last month and had been in touch with family and friends nearly daily until her disappearance.

Police were due to formally identify the body and conduct a postmortem examination on Monday but earlier said they believed it was Millane.

Tributes to Millane have been placed close to the area where the body was found. New Zealanders have also paid tribute to her on social media, with the hashtag #herlightourlove.

New Zealanders from the North and South Islands have offered tributes, from a woman who photographed her green paddock in Paeroa and said she wished Millane had seen “the real New Zealand”, to a snap of the harbour at sunset in Whangarei, and a yacht with the moon dipping in the Pacific Ocean.

#HerLightOurLove: New Zealanders pay tribute to Grace Millane

Read more

Many Kiwis offered Māori words of condolence, including offering aroha (love) to the grieving family, kia kaha (stay strong) and aroha nui (big love) and said they were sorry that “we couldn’t protect you”.

Vigils are planned for Wednesday in Auckland and Wellington.

The death has shocked New Zealand, which is usually regarded as a safe place to travel and averages fewer than 50 homicides a year in a population of 4.8 million. Tourism New Zealand, which described the death as “unimaginable”, said travellers would be left concerned about what is usually considered a safe destination.

Australian Associated Press and Agence France-Presse contributed to this report