(Updates with details, changes dateline from OTTAWA)
By Christinne Muschi
MONCTON, New Brunswick, June 5 (Reuters) - Canadian police mounted a massive hunt on Thursday 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, some in armored vehicles and some with dogs, 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 Moncton, a city of 70,000 in the East Coast province of New Brunswick.
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 Bourque had been spotted three times in Moncton since the Wednesday shootings, 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 3.45 p.m. EDT (1945 GMT).
Northwest Moncton was largely deserted. Some residents took no chances and fled as soon as they heard about the shootings.
"We left last night but in such a hurry that we left our patio door unlocked and our windows open. So we came back in the morning to lock up and checked inside of the house. I have a fear I have never had before," said Dan Parlee, 33.
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.
The killings spurred an outpouring of grief on social media.
"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.
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.
Media in Moncton published a photograph of a man wearing camouflage clothing and a black headband and carrying a rifle. Reuters could not immediately authenticate the picture.
A Facebook page purporting to belong to the shooter was filled with posts critical of the police and those who back gun control.
City officials said there were no murders in Moncton in 2013, and this year none had been recorded until Wednesday.
Lorraine Roy, 76, lives with her husband in an apartment in the area under lockdown. She told Reuters by phone: "We heard the helicopters all night and kept our lights off all night. We are on the third floor and did not want to take any chances if someone pointed a gun this way."
She said she was shocked by the events because "Moncton is a very quiet and safe place, especially this area".
In Ottawa, legislators in the House of Commons stood for a moment in silence. The flag on top of the Parliament Buildings flew at half mast.
The issue of gun control is a sensitive one for Canada's Conservative government, which has a strong base of support in rural areas and parts of the country typically more opposed to restricting firearms.
In 2012 the Conservatives, acting against the advice of some police forces, scrapped a national registry of long guns and rifles, saying it was wasteful and did nothing to cut crime.
The previous Liberal government set up the registry in 1995 in the wake of a 1989 Montreal massacre in which a gunman with a rifle murdered 14 women at a college.
Canada's National Firearms Association, representing gun owners, said the shooting showed "Canada's excessive firearms control system" had failed again. (Additional reporting by Ed Stoddard in Halifax, Nova Scotia; Editing by Jeffrey Hodgson, W Simon, Sofina Mirza-Reid and Peter Galloway)