The federal government has accused Labor of putting politics over public safety after the Senate rejected its bid to introduce mandatory minimum sentences for gun traffickers.

The government had proposed mandatory minimums of five years' jail for trafficking firearms within, into and out of Australia.

But Labor, Greens and crossbenchers joined forces to oppose the mandatory minimum in the upper house on Monday, instead amending the legislation to create new aggravated offences for firearms trafficking attracting penalties of 30 years' jail or life for the worst offenders.

The government supported the tougher penalties but will seek to reinstate the mandatory minimum sentences when the legislation comes before the lower house where it has the numbers.

Attorney-General George Brandis said removing mandatory minimums weakened the legislation.

"Courts in sentencing already take into account circumstances of aggravation."

The "preponderate view" was that when it came to premeditated offences like firearms trafficking, the inevitability of jail had a deterrent effect, he told parliament.

In a statement, Justice Minister Michael Keenan accused Labor of "blatant hypocrisy", insisting it had previously supported mandatory minimum sentences to combat serious crimes like people smuggling.

"Labor's vote against mandatory minimum sentences for illegal firearms trafficking is a vote in support of criminals," he said.

"There will be no deterrent to the criminals that peddle in this illicit trade."