Officials said on Tuesday a landmark US and British-backed code of conduct signed by private security operators, including some operating in Iraq and Afghanistan, would stop the firms being used as mercenaries.

Britain announced at the signing that it intended to make the code, which is aimed at preventing abuse and reining in excess violence in lawless conflict zones, compulsory for security providers it contracts.

About 58 companies, including US firms Triple Canopy, Xe Services -- formerly Blackwater -- and Britain's G4 Security signed up, while the code has the backing of 35 countries, said Swiss officials who brokered the deal.

"We are turning the page," Swiss state secretary for foreign affairs Peter Maurer told journalists.

"You have to choose whether you are going to be a private security contractor or engaging in warfare," he added, underlining that a pledge to restrict firearms to self defence only would rule out offensive operations or mercenaries.

"You are not allowed to be a mercenary and take part" in the international code, said Andrew Clapham, director of the Geneva academy of international humanitarian law, who helped draw it up.

The 15-page code, which took 14 months to negotiate, emerged amid concern about the "exponential growth" of contractors providing security in conflict areas and their role in guarding embassies, officials, company executives and aid agencies.

The UN working group on mercenaries this year pressed for stronger binding regulation of the private military security industry.

It warned that such firms, often run by ex-troops, were in a legal grey area that sometimes strayed from protection duty into "new forms of mercenary activities" with the "privatisation of war."

Diplomats and company executives argued that the voluntary code would fill a gap by setting a minimum standard and marked a step towards greater accountability.

"This code has the potential to be a monumental step forward," said Devon Chaffee of campaign group Human Rights First.

Maurer warned that it "will only be credible if it is followed by short, medium and long term change in behaviour."

Michael Clarke, director of public affairs for G4S, which generates 11 billion dollars a year, acknowledged that security providers "didn't always get it right" in highly insecure areas where staff worked under threat.

"Local institutions may not be strong enough to ensure that people operating there, including our people, are properly held to account. That is, as we see it, the rationale for this code," he explained.

Blackwater became notorious in 2007 when its guards protecting a convoy opened fire in a busy Baghdad square, killing as many as 17 civilians.

Two former security guards also went on trial in the United States in September accused of the murder of two Afghan citizens in a 2009 shooting.

Afghanistan's government has ordered private security firms to disband and leave the country amid anger among ordinary Afghans who regard them as private militias acting above the law.

Guy Pollard, a diplomat at the British mission in Geneva, acknowledged that the use of private security services on armed duty carried "significant risks."

Pollard said the British government would incorporate the code "into each contract we have with a private security company."

"We will only give contracts to companies that can show they meet the minimum standard we have set for this industry," he added.

US State Department legal adviser Harold Koh welcomed the code as an opportunity to raise standards and "address gaps in oversight."

The companies agreed to standards in recruitment, vetting personnel, training, control mechanisms, compliance with local and international laws and protection of human rights.

The code includes limits on the use of force and an assurance that staff cannot invoke contractual obligations or "superior orders" in a conflict zone to justify crimes, killings, torture, kidnappings, detentions.