A gunman broadcast live footage on Facebook of the attack on one mosque in the city of Christchurch, mirroring the carnage played out in video games, after publishing a "manifesto" in which he denounced immigrants.
New Zealand was placed on its highest security threat level, Ardern said, adding that four people in police custody, three men and one woman, held extremist views but had not been on any police watchlists.
The visiting Bangladesh cricket team was arriving for prayers at one of the mosques when the shooting started but all members were safe, a team coach told Reuters.
Police Commissioner Mike Bush said 49 people had been killed at two mosques and one man in his late 20s charged with murder.
"It is clear that this can now only be described as a terrorist attack," Ardern said.
The video footage widely circulated on social media, apparently taken by a gunman and posted online live as the attack unfolded, showed him driving to one mosque, entering it and shooting randomly at people inside.
One man who said he was at the Al Noor mosque told media the gunman was white, blond and wearing a helmet and a bulletproof vest. The man burst into the mosque as worshippers were kneeling for prayers.
"He had a big gun... he came and started shooting everyone in the mosque, everywhere," said the man, Ahmad Al-Mahmoud. He said he and others escaped by breaking through a glass door.
An anonymous post on Friday on the discussion site 8chan, known for a wide range of content including hate speech, said the writer was going to "carry out an attack against the invaders," and included links to a Facebook live stream, in which the Friday shooting appeared, and a manifesto.
The manifesto cited "white genocide," a term typically used by racist groups to refer to immigration and the growth of minority populations, as his motivation.
The Facebook link directed users to the page of a user called brenton.tarrant.9.
A Twitter account with the handle @brentontarrant posted on Wednesday images of a rifle and other military gear decorated with names and messages connected to white nationalism. What looked like the same weapons appeared in the livestream of the mosque attack on Friday.
It was not immediately clear if the attacks were carried out by the same man.
"This is one of New Zealand's darkest days," Adern said.
Australian Prime Minister Scott Morrison said one of the men in custody was Australian.
All mosques in New Zealand had been asked to shut their doors, police said.
The killings were condemned by political and Islamic leaders across Asia.