Image copyright AFP Image caption The gun attacks caused an outpouring of grief in New Zealand

A man accused of deadly attacks on mosques in the New Zealand city of Christchurch a year ago has pleaded guilty to 51 charges of murder.

Brenton Tarrant, 29, also admitted the attempted murder of another 40 people, and one terrorism charge.

He had previously denied the charges and was due to go on trial in June.

The gun attacks at two mosques sent shockwaves around the world. In the wake of the killings, New Zealand brought in stricter gun laws.

New Zealand is in a state of lockdown due to the coronavirus outbreak and the plea was made at a scaled-down court hearing in Christchurch High Court on Thursday.

No members of the public were allowed in to the hearing and Tarrant, from New South Wales, Australia, and his lawyers appeared via video link.

A representative of the two mosques that were attacked was allowed to attend the hearing to represent the victims and their families.

Image copyright Getty Images Image caption The hearing at Christchurch High Court was closed to the public

Judge Justice Cameron Mander said: "It is regrettable that the Covid-19 restrictions that presently apply do not permit victims and their families to travel to be present in the courtroom when the defendant entered his pleas of guilty."

Sentencing on the 92 charges will take place at a date yet to be set. Tarrant was remanded in custody until 1 May when the court hopes to be able to set a sentencing date.

Justice Mander added: "There is no intention to sentence the defendant before the court returns to its normal operations and at a time when the victims and their families can attend court in person."

Farid Ahmed, who lost his wife Husna in the attack on Al Noor Mosque (Masjid An-Nur), told TVNZ that many would be relieved they did not have to go through the trial, but others would feel very sad, still thinking about their loved ones.

Speaking of the gunman, he said: "I have been praying for him and he has taken the right direction. I am pleased he is feeling guilty, it is a good start."

Surprise guilty plea avoids painful trial

Analysis by Simon Atkinson, BBC News

Minutes after Brenton Tarrant changed his plea, families of mosque attack victims began finding out on the rumour mill.

And to everyone it seems to have been a huge shock and surprise.

I was in Christchurch just a couple of weeks ago for the first anniversary of the attacks. The trial looming in early June was something many told me they were dreading.

Witnesses being forced to revisit what happened; graphic CCTV and the head-mounted camera of the attacker being played frame by frame.

But a few said they were - in a way - looking forward to it, to seeing justice being done. It gave them a focus.

One father told me he had learned that his son's actions in Al Noor Mosque had been heroic. He had wanted to see and hear that in court for himself - and for the world to see and hear it.

People like him will no longer have the opportunity to get that level of detail to what happened to their loved ones.

And, because of the Covid-19 lockdown, they did not even get the chance to hear the guilty pleas in person.

But not having a trial takes away one real fear: that Tarrant would use the occasion as a platform to push his right-wing agenda of hate, something the justice system, the media and most importantly the Muslim community were desperate to avoid.

How did the attacks unfold?

The shootings on 15 March 2019 began when the gunman drove to the Al Noor mosque in Christchurch, entered the building and began shooting.

Less than 30 seconds later, he returned to his car, picked up another weapon, then re-entered the mosque and resumed his attack.

Footage from a headcam he was wearing showed him pass from room to room, killing as he went. The shootings were broadcast on Facebook Live.

He then drove to the Linwood mosque where he shot two people outside and then shot at the windows.

A man from inside the mosque came outside, picked up one of the attacker's shotguns, and chased him away.

Two police officers then chased and arrested the suspect.

More on the Christchurch attacks

Media playback is unsupported on your device Media caption The BBC report from the day of the shootings

What was the aftermath of the attacks?

Speaking on the first anniversary of the massacre, Prime Minister Jacinda Ardern said New Zealand had "fundamentally changed" because of the attacks.

She acknowledged that "much more" needed to be done to stop radicalisation in the country.

"The challenge for us will be ensuring in our everyday actions, and every opportunity where we see bullying, harassment, racism, discrimination, calling it out as a nation," she said.

"That is when we'll show we each individually have a role to play in making sure that New Zealand has changed fundamentally for the better."

Media playback is unsupported on your device Media caption New Zealand has "fundamentally changed" since the Christchurch mosque attacks, says PM

Immediately after the attacks, Ms Ardern said the government would bring in laws to make it harder for New Zealanders to access firearms.

In April, less than a month after the shootings, parliament voted by 119 to 1 to change the gun laws.

Military-style semi-automatic weapons were banned, as were parts that could be used to build prohibited firearms.

In June, a buy-back scheme began, where the government would compensate owners of newly-illegal weapons.