Gordon Brown promised severe punishment for people caught carrying firearms as he met a special police task force tackling gun crime in Manchester.
Mr Brown discussed the issue with Michael Todd
The prime minister met officers at the task force's base at Greenheys police station in Moss Side.
He also talked to families who have had relatives murdered by gang members.
The visit came as officers continue to hunt the killers of Jessie James, 15, gunned down a few streets away in a local park in September 2006.
The government set up its own ministerial task force in the wake of the murder of 11-year-old Rhys Jones in Liverpool in August.
Both murders remain unsolved, amid growing concern about gun violence on Britain's streets.
The visit coincided with police in the capital revealing plans for talks with leaders of south London's most violent gangs in an attempt to cut gun crime.
Mr Brown renewed the government's pledge to take a tough stance on gun crime during his meeting with Greater Manchester Police's Xcalibre Task Force on Friday morning.
He said: "The reason I'm here is that it is intolerable that any young life is lost, any family bereaved, because of gun and gang crime.
"I want to see it rooted out. I want to not only send my condolences to families who have suffered, but assure them we will do everything in our power to root out gun and gang crime.
"If you are harbouring guns or have a gun in your possession, you will be sentenced with a very severe penalty for doing so."
The task force has been working to break the city's crime gangs and officers have visited the Los Angeles police department to look at the methods used there.
Michael Todd, chief constable of Greater Manchester Police, said: "Tackling guns and gangs in Manchester is one of our absolute priorities.
"The really important thing is he will see the men and women on the Xcalibre Task Force making a real difference to people's lives, bringing these people to account."
Hours before Mr Brown's visit, officers seized six guns at a suspected cannabis farm in Tellson Crescent, Salford.
A man in his 40s and a woman in her 30s were arrested and are being questioned on suspicion of firearms offences, possession of cannabis and the illegal abstraction of electricity.