Britain’s highest court in the land has given strong backing to the use of random stop-and-search powers to tackle gun and knife crime and gang violence.

Critics have said the UK’s legal powers have been used disproportionately by police against black people, but five supreme court justices emphasised the capability for saving lives.

The court held that there was a risk that a random, “suspicionless”, power of stop-and-search could be used in an arbitrary and discriminate manner in individual cases. But the deputy president of the supreme court, Lady Hale, sitting with Lord Clarke, Lord Reed, Lord Toulson and Lord Hodge, ruled that there were adequate safeguards in place and that there were “great benefits to the public in such a power”, particularly to the black community.

In the first case of its kind, Hale said: “Put bluntly, it is mostly young black lives that will be saved if there is less gang violence in London and some other cities. It is the randomness and therefore the unpredictability of the search which has the deterrent effect and also increases the chances that weapons will be detected.”

The five judges unanimously ruled that section 60 of the 1994 Criminal Justice and Public Order Act, which allows random searches, was “in accordance with the law” and therefore compatible with the European convention on human rights.

The court dismissed a legal challenge, brought by a black mother, from a community “scarred by knife crime”, who said she had taken legal action to ensure there were adequate safeguards so the black and ethnic minority community could retain faith in the police.

Ann Juliette Roberts, who is in her early 40s and from Upper Edmonton, north London, was subjected to a search after failing to pay a bus fare and “behaving suspiciously” on a bus route known to be used by gang members in the Haringey area of London.

Roberts, who is of African-Caribbean heritage and has a grown-up son, argued that suspicionless search powers were being used disproportionately against black people, breaching their human rights. Both the high court and court of appeal rejected her case and she took it to the supreme court.

Dismissing her latest appeal, Hale and Reed observed in a lead ruling that the purpose of the searches was to “reduce the risk of serious violence where knives and other offensive weapons are used, especially that associated with gangs and large crowds”.

The judges said: “It must be borne in mind that many of these gangs are largely composed of young people from black and minority ethnic groups. While there is concern that members of these groups should not be disproportionately targeted, it is members of these groups who will benefit most from the reduction in violence, serious injury and death that might result from such powers.”

The court heard the 149 bus route, used by Roberts in September 2010, was “a hotspot” for knife crime. Stop-and-search operations had been authorised because of fears of more violence involving local gangs.

Roberts was arrested for obstructing the search and handcuffed. She was taken to the ground by an officer when she continued to resist. No weapons were found. A caution she received for the incident was later quashed after she was found to be of good character.