Canadian police are mounting a massive hunt for a 24-year-old man armed with high-powered weapons who they suspect shot dead three police officers and wounded two more in the eastern city of Moncton.

The incident was one of the worst of its kind in Canada, where gun laws are stricter than in the United States and fatal attacks on police are rare.

Hundreds of police cordoned off a large area in the city's northwest and warned residents to stay inside their homes and lock their doors. At one point officers surrounded a house but later left without making an arrest.

Schools and government offices were shut in the city of 70,000.

Police told residents not to tweet the locations of officers for fear they could be helping the suspect, who they named as Justin Bourque. He has no previous criminal record.

Police said Mr Bourque had been spotted three times in Moncton since the shootings on Wednesday, most recently just after dawn on Thursday.

"Our search for the suspect is still ongoing," Royal Canadian Mounted Police (RCMP) spokeswoman Chantal Ferrer told a news conference in Moncton at 8.45pm.

Police were alerted on Wednesday afternoon by a member of the public who spotted an armed man in camouflage clothing walking down a residential street. When police arrived, the man moved into a nearby wooded area and opened fire.

Three officers were killed and two more were taken to hospital, where both had surgery on Thursday. One of the two was later released.

"This is like working through your worst nightmare," said Roger Brown, commander of the RCMP in New Brunswick.

The last mass killing of police took place in Mayerthorpe in the western province of Alberta in 2005, when a gunman killed four officers before shooting himself. Those killings were the most the RCMP had suffered in a single day in 100 years.

Mr Brown said the entire RCMP was in mourning after what he called a horrendous crime.

Earlier in the day he visited some relatives of the dead and injured. "They are hurting. There is actually no way to describe the level of hurt," he said.