Venezuela's President Nicolas Maduro signed a gun control bill into law in a bid to rein in the country's runaway violent crime.

"I hereby sign into law this gun control law, for peace in our nation," Maduro said on Friday in an address in Vargas state.

The bill will allow sentences of up to 20 years in prison for any civilian convicted of illegally carrying or selling a firearm.

It also restricts the sale of ammunition to civilians, and bans weapons from being shown in public places.

"Any arm that is confiscated will be destroyed immediately ... the sales of weapons and ammunition also ends," said National Assembly President Diosdado Cabello.

There are some exceptions: people are allowed to use weapons to protect their property and themselves when in danger, and security personnel can use them when transporting valuable items.

The bill was promoted by late president Hugo Chavez, a leftist-populist in power since 1999 who died on March 5.

The ruling socialist party, or PSUV, and two opposition parties approved the bill.

In the first quarter of 2013, there were 3,400 murders. That followed another year of bloodletting that saw about 16,000 homicides nationwide in 2012, according to government data.

There were 15 million firearms - legal and illegal - in a country of 29 million in 2009.