The agreement - which came at the end of a conference reviewing the 1970 Nuclear Non-Proliferation Treaty (NPT) - brought a rare consensus on a global disarmament agenda.
The United Nations welcomed the commitment, although environmentalists said it would not produce any real action.
The BBC's defence correspondent, Jonathan Marcus, says the pledge to disarm is an important symbolic step, but that a nuclear-free world is unlikely to become a reality soon.
The conference's final document, approved by 187 countries, puts pressure on four states who remain outside the treaty - Israel, India, Pakistan and Cuba - to accede to it.
It is widely accepted that until they do, the commitment by the US, Russia, China, France and the UK to give up nuclear weapons will not be carried out.
No timetable
The environmental pressure group Greenpeace said the nuclear states' pledge to disarm merely reiterated a promise they made when the treaty was first signed, 30 years ago.
The group's disarmament co-ordinator, William Peden, told the BBC that on the record of the last three decades it was unlikely they would ever give up their weapons.
But UN Secretary-General Kofi Annan hailed it as a "significant step".
And a group of countries who form the New Agenda Coalition said the agreement was "an important landmark on which to build a nuclear weapons-free world".
The coalition - including Brazil, Egypt, Ireland, Mexico, New Zealand, South Africa and Sweden - had criticised an earlier version of the pledge for describing the elimination of nuclear weapons as an "ultimate goal".
Concerns
The BBC's UN correspondent says that significant concerns remain.
India, Pakistan and Israel show no sign of abandoning their nuclear weapons programmes, and Washington's interest in a national anti-missile defence shield threatens to destabilise the present nuclear balance.
The conference's final document for the first time singled out Israel, which is believed to have nuclear weapons, for not signing the treaty and for not placing its nuclear materials under "comprehensive" international safeguards.
Disarmament agenda
The delegates also agreed on a moratorium on weapons testing, further reductions of tactical nuclear weapons and greater transparency by the nuclear powers on reporting about their arsenals.
They agreed to remove plutonium and uranium from nuclear warheads and to negotiate within the next five years a treaty banning production of fissile weapon materials.
In addition, the final document called for diminishing the role of nuclear weapons in national security policies and committed the US and Russia to cut their long-range nuclear warheads.
Washington and Moscow are thought to have more than 30,000 strategic, tactical or stockpiled warheads between them.