New Zealand has been trying to come to terms with the deaths of 49 people shot to death at two mosques during midday prayers on Friday.

Most, if not all of them, were gunned down by an immigrant-hating white supremacist who apparently used a helmet-mounted camera to broadcast live video of the slaughter on Facebook.

One man was arrested and charged with murder, and two other armed suspects were taken into custody while police tried to determine what role, if any, they played in the cold-blooded attack that stunned New Zealand, a country so peaceful that police officers rarely carry guns.

“It is clear that this can now only be described as a terrorist attack,” prime minister Jacinda Ardern said, noting that many of the victims could be migrants or refugees.

She pronounced it “one of New Zealand’s darkest days”.

The gunman who carried out at least one of the mosque attacks left a jumbled, 74-page manifesto that he posted on social media under the name Brenton Tarrant, identifying himself as a 28-year-old Australian and white supremacist who was out to avenge attacks in Europe perpetrated by Muslims.

He also live-streamed in graphic detail 17 minutes of his rampage at Al Noor Mosque, where, armed with at least two assault rifles and a shotgun, he sprayed worshippers with bullets over and over, killing at least 41 people.

Several more people were killed in an attack on a second mosque in the city a short time later.

At least 48 people were wounded, some critically.

Police did not immediately say whether the same person was responsible for both shootings.

They gave no details about those taken into custody except to say that none had been on any watch list.

In the aftermath, the country’s threat level was raised from low to high, police warned Muslims against going to a mosque anywhere in New Zealand, and the national airline cancelled several flights in and out of Christchurch.

World leaders condemned the violence and offered condolences.

Pakistan’s prime minister Imran Khan and other Islamic leaders pointed to the bloodbath and other such attacks as evidence of rising hostility toward Muslims.

“I blame these increasing terror attacks on the current Islamophobia post-9/11 where Islam & 1.3 bn Muslims have collectively been blamed for any act of terror by a Muslim,” Mr Khan tweeted.

New Zealand Mosque ShootingPolice gather outside the Linwood mosque (Mark Baker/AP)

President Donald Trump tweeted: “We stand in solidarity with New Zealand” and pledged to give the country any assistance it needs.

New Zealand, with five million people, has relatively loose gun laws but few gun homicides.

It is also generally considered to be welcoming to migrants and refugees.

In the wake of the slaughter, the prime minister said that immigrants “have chosen to make New Zealand their home, and it is their home. They are us”.

She said the attack reflected “extremist views that have absolutely no place in New Zealand.”

At the Al Noor mosque, witness Len Peneha said he saw a man dressed in black and wearing a helmet with some kind of device on top enter the house of worship and then heard dozens of shots, followed by people running out in terror.

Mr Peneha, who lives next door, said the gunman ran out of the mosque, dropped what appeared to be a semi-automatic weapon in his driveway and fled.

Mr Peneha then went into the mosque to help the victims.

“I saw dead people everywhere. There were three in the hallway, at the door leading into the mosque, and people inside the mosque,” he said.

“I don’t understand how anyone could do this to these people, to anyone. It’s ridiculous.”

Facebook, Twitter and Google companies scrambled to take down the gunman’s video, which was widely available on social media for hours after the horrific attack.

New Zealand Mosque ShootingPolice stand at a roadblock (Mark Baker/PA)

In the video, the killer spends more than two minutes inside the mosque spraying terrified worshippers with gunfire.

He then walks outside, where he shoots at people on the sidewalk.

Children’s screams can be heard in the distance as he returns to his car to get another rifle.

He walks back into the mosque, where there are at least two dozen people lying on the ground.

New Zealand Mosque ShootingPolice attempt to move people away from outside a mosque (Mark Baker/PA)

After going back outside and shooting a woman there, he gets back in his car, where the song Fire by the English rock band The Crazy World Of Arthur Brown can be heard blasting.

The singer bellows, “I am the god of hellfire!” and the gunman drives off.

The second attack took place at the Linwood mosque about three miles away.

New Zealand Mosque ShootingNew Zealand’s prime minister Jacinda Ardern gives a press conference (TVNZ/AP)

Mark Nichols told the New Zealand Herald that he heard about five gunshots and that a worshipper returned fire with a rifle or shotgun.

The footage showed the killer was carrying a shotgun and two fully automatic military assault rifles, with an extra magazine taped to one of the weapons so that he could reload quickly.

He also had more assault weapons in the boot of his car, along with what appeared to be explosives.

The gunman’s manifesto was a welter of often politically contradictory views, touching on many of the most combustible issues of the day, among them the Second Amendment right to own guns, Muslim immigration, terrorist attacks and the wealthiest 1%.

New Zealand Mosque ShootingPolice stand guard at Christchurch Hospital (Mark Baker/AP)

He portrayed himself as a racist and a fascist and raged against non-Westerners, but said China is the nation that most aligns with his political and social values.

The gunman said he was not a member of any organisation, acted alone and chose New Zealand to show that even the most remote parts of the world are not free of “mass immigration”.

Last year, New Zealand’s prime minister announced that the country would boost its annual refugee quota from 1,000 to 1,500 in 2020.

Ms Ardern, whose party campaigned on a promise to take in more refugees, called it “the right thing to do”.

Christchurch is home to nearly 400,000 people and is sometimes called the Garden City.

It has been rebuilding since an earthquake in 2011 killed 185 people and destroyed many buildings.

Before Friday’s attack, New Zealand’s deadliest shooting in modern history took place in 1990 in the small town of Aramoana, where a gunman killed 13 people following a dispute with a neighbour.