The High Court in Canberra has upheld the New South Wales anti-consorting laws, which make it an offence for convicted criminals to repeatedly associate with each other.

Three men who were charged under the laws mounted the challenge on the grounds that they infringed the implied right to freedom of association in the constitution and that they were at odds with Australia's international obligations.

The laws were set up in 2012 to target bike gangs and the NSW Government argued they served a legitimate end.

Today the court found the laws are valid and there is no such right to freedom of association.

It also found that although the laws do impinge on the freedom of political communication, in this case they are an appropriate measure in the prevention of crime.

NSW consorting laws: Introduced in 1929 to target 'razor gangs' in Sydney.

Introduced in 1929 to target 'razor gangs' in Sydney. Updated in 2012 to help police deal with organised crime.

Updated in 2012 to help police deal with organised crime. Bans face-to-face, telephone calls and internet contact.

Bans face-to-face, telephone calls and internet contact. Charges can be laid after an official police warning.

Charges can be laid after an official police warning. Punishable by up to 3 years jail and/or $16,500 fine.

The court also dismissed claims the laws were at odds with the International Covenant on Civil and Political Rights because that was not in Commonwealth legislation.

The New South Wales Government said it was always confident the laws would hold up to the High Court's scrutiny.

"It is not surprising that criminals don't like the laws and wanted them overturned, but today's decision in the High Court ensures they are here to stay," Attorney-General Brad Hazzard said.

"The anti-consorting laws give police the powers they need to disrupt and dismantle criminal organisations, including outlaw motorcycle gangs."

The laws carry maximum penalties of three years in jail and a $16,500 fine for people who repeatedly consort with convicted offenders after being warned by police.

Two of the men behind the challenge belong to the Nomads bikie gang but the third man is not a bikie and was charged with consorting while grocery shopping with his housemate.

The laws were introduced in the 1920s to tackle Sydney's razor gangs but were later scaled back because of concerns police were abusing their powers.

The New South Wales Parliament revived them in 2012 in response to a wave of gun violence involving bikies and organised crime groups, but police said the legislation was never just intended for gang members.

The case is the latest in a series of High Court battles between bikie gangs and state governments.

The High Court is also considering a challenge to Queensland's new anti-bikie legislation heard in June.