New Zealand’s prime minister has announced a top-level inquiry into the circumstances surrounding the massacre of 50 people in two Christchurch mosques.

Jacinda Ardern said the country’s highest form of investigation, a royal commission of inquiry, was appropriate for “matters of the gravest public importance”.

“It is important that no stone is left unturned to get to the bottom of how this act of terrorism occurred and what, if any, opportunities we had to stop it,” Ardern told reporters at Parliament House in Wellington on Monday.

Her cabinet had previously agreed on holding an inquiry, but had not decided what kind of investigation would be held.

A royal commission is run independently from the government and is chaired by a high court judge. It has the power to compel witnesses to testify and organisations to hand over documents. But it remains up to the courts or government to follow through on any recommendations or findings.

Ardern said the cabinet agreed on Monday a royal commission of inquiry “will look at what could have or should have been done to prevent the attack”.

An Australian, Brenton Tarrant, has been charged with murder in relation to the 15 March attacks.

The royal commission will look at his travel to and from New Zealand, internationally, his activities in New Zealand, his use of social media and his connection to others.

The agencies taking part in the inquiry would include the New Zealand Security Intelligence Service, the Government Communications Security Bureau, police along with Customs and Immigration.

Ardern said that the royal commission’s terms of reference would be finalised in the next two or three weeks.

Fifty people died in the shootings at Al Noor and Linwood mosques in Christchurch, in what is New Zealand’s worst ever terrorist attack.

The county’s intelligence agencies have been under pressure for the past two weeks after they were accused of not placing enough importance on monitoring rightwing extremists.

The opposition leader, Simon Bridges, had also called for a royal commission to look at the country’s security legislation and ensure “New Zealanders are kept safe”.

Ardern said she and other ministers would soon meet with Microsoft to discuss the role of social media following the sharing of live-streamed video of the alleged gunman’s attack.

The commission follows the chief censor making it illegal to possess and share both the live-streamed video of the shooting and a document the gunman shared on social media before the attack took place.

David Shanks officially classed the so-called manifesto as “objectionable” and told anyone in possession of it to destroy it.