GENEVA — The top human rights official at the United Nations warned the United States authorities on Friday that their efforts to force Apple to unlock an iPhone belonging to a gunman risked helping authoritarian governments and jeopardizing the security of millions around the world.

The remarks by Zeid Ra’ad al-Hussein, the United Nations high commissioner for human rights, came as American investigators continued to press Apple to write software to help them gain access to an iPhone used by one of the gunmen in a shooting in San Bernardino, Calif., in December. Though the F.B.I. says it is a one-time request, Apple and others have raised concerns that the case could set a precedent and could force technology firms to install so-called back doors in devices, potentially invading customer privacy.

Mr. al-Hussein said that American law enforcement agencies, in trying to break the encryption protecting one phone, “risk unlocking a Pandora’s box,” and that there were “extremely damaging implications” for the rights of many millions of people, with possible effects on their physical and financial security.

“A successful case against Apple in the U.S. will set a precedent that may make it impossible for Apple or any other major international I.T. company to safeguard their clients’ privacy anywhere in the world,” Mr. al-Hussein said in a statement. “It is potentially a gift to authoritarian regimes, as well as to criminal hackers.”