Six years in the making, the international commitment could prevent 700,000 deaths a year, say experts.
It is the fourth time a UN declaration has been reached on a health issue - following HIV in 2001, non-communicable diseases in 2011 and Ebola in 2013.
The signatories now have two years to report back with an action plan.
Experts say treatment-resistant infections pose one of the biggest known threats to humanity today.
Without urgent action, it is conceivable that simple infections could soon become entirely untreatable with existing drugs.
The problem has been caused by over-use of antimicrobial medicines for humans, animals and agriculture.
Repeated exposure allows bacteria and other infections, including HIV and malaria, to learn how to dodge these treatments by mutating and evolving.
Unless new effective treatments are found, routine medical procedures such as hip operations and Caesarean sections could become too dangerous to perform.
The nations have committed to:
Dr Margaret Chan, Director-General of the WHO, said: "Antimicrobial resistance poses a fundamental threat to human health, development, and security.
"The commitments made today must now be translated into swift, effective, lifesaving actions across the human, animal and environmental health sectors.
"We are running out of time."
The UK has been at the forefront of a campaign to get global action on superbugs.
It has pledged £369m to international antimicrobial resistance (AMR) programmes in the past two years.
Earlier this year, Lord O'Neill, who led a government review on AMR, called for a $2bn (£1.5bn) investment in global innovation funding for research by 2020.
The signatories at the United Nations General Assembly in New York have agreed to pool funding, already totalling about $790m (£600m).
The UK's chief medical officer, Prof Dame Sally Davies, said: "Drug-resistant infections are firmly on the global agenda, but now the real work begins.
"We need governments, the pharmaceutical industry, health professionals and the agricultural sector to follow through on their commitments to save modern medicine."
The UK has set its own target to reduce inappropriate prescriptions and the incidence of high risk bacterial infections in hospitals by 50% by 2020 and cut the level of antibiotic use in the agricultural sector to 50mg/kg by 2020.
The 193 countries of the United Nations have agreed a landmark declaration to rid the world of drug-resistant infections or "superbugs".