Before the assembly voted on the text, the 193-member world body had narrowly voted to require a two-thirds majority for approval as sought by Arab nations, rather than the simple majority urged by the United States.
The vote to require a two-thirds majority was close, 75-72, with 26 abstentions and several countries changing their votes to "yes" at the last minute.
US Ambassador Nikki Haley told the assembly before the vote that it could make history and unconditionally speak out against Hamas, which she called "one of the most obvious and grotesque cases of terrorism in the world."
"What the UN chooses to do today will speak volumes about each country's seriousness when it comes to condemning anti-Semitism," Haley said. "Because there is nothing more anti-Semitic than saying terrorism is not terrorism when it's used against the Jewish people and the Jewish state."
Both the United States and European Union have classified Hamas as a terrorist group.
Hamas official Sami Abu Zuhri told the Reuters news agency, "Rejecting the American drafted resolution against the resistance represents a blow to the American administration and reaffirms the legitimacy of the resistance."
Palestinian President Mahmoud Abbas, whose Fatah party has been locked in a power struggle with Hamas, welcomed the resolution's defeat saying, "The Palestinian presidency will not allow for the condemnation of the national Palestinian struggle."
The US attempt to condemn Hamas and demand that the militant group stop firing rockets into Israel, using "airborne incendiary devices," and putting civilians at risk sparked a Palestinian-backed amendment sponsored by Bolivia.
Peace resolutionsThe amendment outlined the basis for comprehensive Israeli-Palestinian peace and referred to a December 2016 Security Council resolution that condemned Israeli settlements in the West Bank and east Jerusalem as a "flagrant violation" of international law.
It also reaffirmed "unwavering support" for a two-state solution to the Israeli-Palestinian conflict - issues that were not included in the US draft.
However, before the vote on the US draft resolution, Bolivian Ambassador Sasha Llorentty Soliz withdrew the amendment.
That was because the Palestinians and their supporters wanted a vote instead on a short rival resolution sponsored by Ireland that included the exact language of the amendment.
After the US draft on Hamas was not adopted, the General Assembly overwhelmingly approved the Irish resolution by a vote of 156-6, with 12 abstentions.
It called for "the achievement, without delay, of a comprehensive and lasting peace in the Middle East" on the basis of UN resolutions, singling out the December 2016 measure, and reaffirms "unwavering support ... for the two-state solution of Israel and Palestine, living side by side in peace and security within recognized borders, based on the pre-1967 borders."
The two rival resolutions reflect the deep divisions among the 193 UN member states over the decades-old Israeli-Palestinian conflict and the failure to end it.
Resolutions adopted by the General Assembly are non-binding, however, they carry political weight and are seen as a barometer of world opinion.
av/sms (AP, AFP)
Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.