At least 40 people have been killed in a mass shooting at two mosques in Christchurch, New Zealand, prime minister Jacinda Ardern has said.

Police declared a “critical incident” after the initial, deadliest attack began at the Masjid Al Noor mosque in Deans Avenue – where up to 500 people are thought to have been worshipping – and warned residents an “active shooter” was in the area.

A second shooting took place at a mosque on Linwood Avenue. Police urged mosques across the country to close their doors and worshippers to stay away.

One Australian national and three other people have been taken into custody. Facebook says it is working to take down versions of what appears to be a live stream of the shooting, while a 74-page anti-immigrant manifesto purporting to be penned by the attacker has also been removed online.

New Zealand police wrote on Twitter: “Police [are] responding to a very serious and tragic incident involving an active shooter in central Christchurch. One person is in custody, however police believe there may be other offenders. This is an evolving incident.”

Ms Ardern called the attack “one of New Zealand’s darkest days”.

Radio New Zealand (RNZ), the public broadcaster, cited a witness as saying he had seen four people on the ground and “blood everywhere” at the first mosque.

Others witnesses told the New Zealand Herald they had heard more than two dozen gunshots.

Members of the Bangladesh cricket team were reportedly caught up in the Deans Avenue incident but not harmed.

Police Commissioner Mike Bush said in a statement: “Police are responding [at] full capability to manage the situation, but the risk environment remains extremely high.

“Police recommend that residents across Christchurch remain off the streets and indoors until further notice. Christchurch schools will be locked down until further notice.” The schools lockdown was later lifted.

At least 49 killed in New Zealand terror attack Show all 17 1 /17 At least 49 killed in New Zealand terror attack At least 49 killed in New Zealand terror attack Paramedics assist a man wounded in the shootings EPA At least 49 killed in New Zealand terror attack Bloodied bandages lie on the road following the shootings EPA At least 49 killed in New Zealand terror attack Police officers console a man at the scene of the shootings AP At least 49 killed in New Zealand terror attack New Zealand Prime Minister Jacinda Ardern speaks at a press conference following the shootings Getty At least 49 killed in New Zealand terror attack Masjid Al Noor mosque on Deans Avenue in Christchurch, the scene of the first shooting EPA At least 49 killed in New Zealand terror attack A tribute left near the Linwood Masjid mosque. The letter reads: thinking of everyone on this most tragic of days. We are neighbours & community here in Linwood & our hearts are with you Getty At least 49 killed in New Zealand terror attack Armed police stand at the scene of the attack AFP/Getty At least 49 killed in New Zealand terror attack A forensic official works at the scene AFP/Getty At least 49 killed in New Zealand terror attack A car damaged in the shooting AFP/Getty At least 49 killed in New Zealand terror attack Armed police stand at the scene of the attack Getty At least 49 killed in New Zealand terror attack A survivor stands outside Christchurch hospital Getty At least 49 killed in New Zealand terror attack Emergency responders help a wounded man at the scene of the shooting at a mosque in Christchurch AP At least 49 killed in New Zealand terror attack People wait near the scene of the shootings AP At least 49 killed in New Zealand terror attack Paramedics help a wounded man at the scene of the shooting at a mosque in Christchurch AP At least 49 killed in New Zealand terror attack Members of the Armed Offenders Squad push back members of the public at the scene EPA At least 49 killed in New Zealand terror attack Ambulances at the scene of the shootings AP At least 49 killed in New Zealand terror attack New Zealand Prime Minister Jacinda Ardern speaks at a press conference following the shootings Getty

RNZ cited Mustafa Farouk, the head of the Federation of Islamic Associations of New Zealand, as saying between 300 and 500 worshippers were likely inside the mosque at the time of the attack. He said he had been told at least six people were wounded.

“Horrified to hear of Christchurch mosque shootings. There is never a justification for that sort of hatred,” said Amy Adams, a member of parliament from the city.

As well as locking down schools, police have reportedly cleared Cathedral Square, where children were staging a climate change protest.

The deadliest shooting occurred at the Al Noor mosque in central Christchurch at about 1.45pm local time.

Witness Len Peneha said he saw a man dressed in black enter the mosque and then heard dozens of shots, followed by people running from the mosque in terror.

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

Support free-thinking journalism and attend Independent events

Mr Peneha said he then went into the mosque to try to help. “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.”

He said he helped about five people recover in his home. He said one was slightly injured. “I’ve lived next door to this mosque for about five years and the people are great, they’re very friendly,” he said. “I just don’t understand it.”

He said the gunman was white and was wearing a helmet with some kind of device on top, giving him a military-type appearance.

Police said there was a second shooting at the Linwood Masjid Mosque.

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

Mr Nichols said he saw two injured people being carried out on stretchers past his automotive shop and that both people appeared to be alive.

A man who claimed responsibility for the shooting left a manifesto online in which he said he was a 28-year-old white Australian who came to New Zealand only to plan and train for the attack.

He said he was not a member of any organisation, but had donated to and interacted with many nationalist groups, though he acted alone and no group ordered the attack.

He said the mosques in Christchurch and Linwood would be the targets, as would a third mosque in the town of Ashburton if he could make it there.

He said he chose New Zealand because of its location, to show that even the most remote parts of the world were not free of “mass immigration”.