WELLINGTON (Reuters) - Nations must work together to stop lone wolf attackers, who take inspiration from each other, NATO’s secretary general Jens Stoltenberg said on Monday, during a visit to a mosque in New Zealand where a gunman killed dozens of people in March.

His comments came as the United States reels from two mass shootings at the weekend that killed 29 people and injured dozens in Texas and Ohio, provoking calls for tighter gun controls and prompting worries over a resurgence of white nationalism and xenophobic politics.

Stoltenberg, making a two-day trip to New Zealand, visited Christchurch, where 51 Muslim worshippers were killed in the attacks on two mosques by a suspected white supremacist.

“These attacks are committed by lone wolves but they are at the same time connected, because they use each other as inspiration and they refer to each other in the different manifestos,” Stoltenberg told state broadcaster TVNZ.

“It highlights that we have to fight terrorism in many different ways, with many different tools.”

The Texas shooter who killed 20 people at a Walmart store expressed support for the Christchurch gunman in his manifesto.

New Zealand authorities have charged Australian Brenton Tarrant, a suspected white supremacist, with murder following the attacks. He has pleaded not guilty to all charges.

Society has to stand up for values of freedom, openness and tolerance, Stoltenberg said.

“We see that many of the terrorists are one of us,” he said. “They are home-grown, they are coming from our own societies. So this is very much also about addressing the root causes.”

Prime Minister Jacinda Ardern, who is due to meet Stoltenberg on Tuesday, said New Zealand would only want to be remembered for the way it rejected the act of violence and hatred.

“This is a global challenge,” she told a news conference later in the day.

“Of course we can do what we can to defeat acts of hatred, violence and racism in our own domestic areas. But, as an international community, we should also be united against acts of hatred, violence and terrorism.”