A US federal appeals court judge on Tuesday declared unconstitutional the law banning the sale of handguns to people under 21 years of age. The judge stated that anyone above the age of 18 should have the right to buy a gun, overturning a longstanding law.

Judge Julius Richardson based his ruling on the fact that 18 year-olds have the constitutional right to vote. He added that when the Constitution had been written, people above 18 were required to join local militia with their own guns. "Our nation's most cherished constitutional rights vest no later than 18," he wrote in his judgement.

"And the Second Amendment's right to keep and bear arms is no different."

Judge Richardson had been appointed to the appeals court in Richmond, Virginia by former president Donald Trump.

The ruling overturns a 1968 law that had imposed a ban on sale of guns to people under 21 years of age. The US Congress had then argued that young adults commit more crimes than older ones.

The latest ruling could lead to a challenge on gun rights and could end up in the Supreme Court. The top court is firmly to the right since Trump named three justices after taking office in 2017.

The case arose from a complaint by a woman, horse-trainer Natalia Marshall, who was 18 when she tried to buy a handgun for protection from her abusive ex-boyfriend.

The ruling came amid a surge in gun violence, with many youths involved in the scores of shootings every week in cities across the country.

Richardson acknowledged the high crime levels, writing that there was no evidence that the 1968 prohibition has led to any meaningful or measurable positive effects.

"We appreciate the seriousness of gun violence in this country and applaud Congress's laudable desire to curb senseless violence," wrote Richardson.