Forty-nine people have been killed and 48 wounded in shootings at two mosques in Christchurch, New Zealand, in the nation's deadliest attack.
Prime Minister Jacinda Ardern described it as a terrorist attack and one of New Zealand's "darkest days".
A gunman identifying himself as an Australian live-streamed the rampage at Al Noor mosque to Facebook. He had espoused racist, anti-immigrant views.
Police say a man in his late 20s has been arrested and charged with murder.
Two other men and one woman were also detained.
No names have been made public. Firearms and explosive devices were recovered, Police Commissioner Mike Bush said.
The gunman live-streaming the attack from a head-mounted camera said he was a 28-year-old Australian called Brenton Tarrant. The footage showed him firing at men, women and children from close range inside the Al Noor mosque.
Facebook said it had removed the suspect's Facebook and Instagram accounts and was working to remove any copies of the footage. The live-stream of the attack lasted for 17 minutes.
The suspect who was charged appeared to have published a document online outlining his intentions as well as details about the plan for the attack. He is due in court on Saturday.
Australian Prime Minister Scott Morrison described the man as an "extremist, right-wing" terrorist. New Zealand Police Commissioner Bush confirmed that the man had not been known in advance to either New Zealand or Australian security services.
How events unfolded
The first report of an attack came from the Al Noor mosque in central Christchurch at 13:40 on Friday (00:40 GMT).
A gunman drove to the front door, entered and fired indiscriminately for about five minutes.
One unnamed survivor told TV New Zealand that he had seen the gunman shoot a man in the chest. The attacker reportedly targeted the men's prayer room in the mosque, then moved to the women's room.
"What I did was basically just waiting and praying, God please, let this guy run out of bullets," the witness said. "He came to this side, he shot this side, he went to another room and went to the ladies' section and shot them. I just heard one of the ladies has died."
The gunman is then said to have driven about 5km (three miles) to another mosque in the suburb of Linwood where the second shooting occurred.
One witness described how one of the worshippers had managed to disarm the man, who ran to a waiting car outside.
It is not clear where the arrests were made. Police also defused "a number of IEDs [improvised explosive devices] attached to vehicles", Mr Bush said.
Mr Bush said a number of firearms had been recovered from both mosques, and explosive devices were found in a car belonging to one of the suspects.
Authorities advised all mosques in the city to shut down until further notice.
According to the latest census figures, Muslims make up about 1.1% of New Zealand's population of 4.25 million.
Numbers rose sharply as New Zealand took in refugees from various war-torn countries since the 1990s.
The main suspect
Social media accounts in the name of Brenton Tarrant were used to post a lengthy, racist document in which the author identified the mosques that were later attacked.
The man says he began planning an attack after visiting Europe in 2017 and being angered by events there.
The document is called "The Great Replacement" - a phrase that originated in France and has become a rallying cry for European anti-immigration extremists.
Although New Zealand police said they had charged a man in his late 20s with murder, they did not identify the man.
Cricket team escapes attack
The attack happened as players from the visiting Bangladesh national cricket team were on their way to pray at Al Noor mosque.
They were "minutes" from being inside, team manager Khaled Mashud told the BBC.
Bangladesh was due to play New Zealand on Saturday but the match has been cancelled.
He added that the team were all "safe and sound" at their hotel but would travel home "in the coming days".
"Players were crying in the bus, they all were mentally affected," the former wicketkeeper said.
"It is clear that this can now only be described as a terrorist attack," Prime Minister Ardern told reporters.
In a tweet, she said: "What has happened in Christchurch is an extraordinary act of unprecedented violence. It has no place in New Zealand. Many of those affected will be members of our migrant communities - New Zealand is their home - they are us."
US President Donald Trump offered his "warmest sympathy and best wishes" to New Zealand. "The US stands by New Zealand for anything we can do. God bless all!" he wrote.
My warmest sympathy and best wishes goes out to the people of New Zealand after the horrible massacre in the Mosques. 49 innocent people have so senselessly died, with so many more seriously injured. The U.S. stands by New Zealand for anything we can do. God bless all!— Donald J. Trump (@realDonaldTrump) March 15, 2019
UK Prime Minister Theresa May offered her "deepest condolences to the people of New Zealand".
On behalf of the UK, my deepest condolences to the people of New Zealand after the horrifying terrorist attack in Christchurch. My thoughts are with all of those affected by this sickening act of violence.— Theresa May (@theresa_may) March 15, 2019
The Queen said she was "deeply saddened by the appalling events in Christchurch today. Prince Philip and I send our condolences".
The Queen has sent the following message to the people of New Zealand.— The Royal Family (@RoyalFamily) March 15, 2019
I have been deeply saddened by the appalling events in Christchurch today. Prince Philip and I send our condolences to the families and friends of those who have lost their lives...(1/2)
Pope Francis offered his "heartfelt solidarity" and was "deeply saddened to learn of the injury and loss of life caused by the senseless acts of violence", Vatican Secretary of State Pietro Parolin said in a telegram.
German Chancellor Angela Merkel said she mourned "with New Zealanders for their fellow citizens who were attacked and murdered out of racist hatred while peacefully praying in their mosques".
And French President Emmanuel Macron called it an "odious attack" and said France stood "against any form of extremism".