The resolution, without naming any countries, says that surveillance and data interception by governments and companies "may violate or abuse human rights."
The United States and key allies Britain, Australia, Canada and New Zealand joined a consensus vote passing the resolution after language which suggested that foreign spying would be a rights violation was weakened.
The resolution said the UN General Assembly's rights committee is "deeply concerned at the negative impact" that surveillance and interception of communications "including extraterritorial surveillance" can have on human rights.
Germany's Chancellor Angela Merkel and Brazil's President Dilma Rousseff have reacted with fury to reports that the US National Security Agency has spied on their phone calls and office communications.
More From This Section
Germany's UN ambassador Peter Wittig said that while the resolution is non-binding it was an important "political message".
Wittig stressed that it was the first time that the UN has said that "unlawful and arbitrary surveillance domestically and extra territorially might violate human rights."