The resolution condemned Hamas for "repeatedly firing rockets into Israel and for inciting violence, thereby putting civilians at risk" and for its military activities in Gaza including constructing tunnels "to infiltrate Israel and equipment to launch rockets into civilian areas".
A vote on whether to necessitate a two-thirds majority was to precede the vote on the actual resolution itself.
"The failure of the American venture at the United Nations represents a slap to the USA administration and confirmation of the legitimacy of the resistance", Hamas spokesman Sami Abu Zahri wrote on Twitter, using a phrase commonly used to refer to armed groups that oppose Israel.
The U.S. urged a simple majority vote on the resolution but just before the final vote, Kuwait and Bolivia were able to get a narrow majority to adopt a rule requiring a two-thirds majority for the resolution's passage which ensured its failure.
Nikki Haley Slams the Failure of the United Nations to Pass a Resolution Condemning Hamas
Their refusal to back the US resolution comes just weeks before the White House prepares to unveil a proposal to get Israelis and Palestinians back to the negotiating table.
"Before the General Assembly can credibly advocate compromise and reconciliation between the Palestinians and Israel, it must on record, unambiguously and unconditionally, condemn Hamas terrorism", Haley told the body before the vote.
Iran's Deputy UN Ambassador Eshagh Al Habib accused the United States of trying to deflect the attention of the world from the root causes of the conflict and said "we recognize Hamas as a legitimate resistance movement fighting for the liberation of Palestinian territory from foreign occupation".
The vote was a personal defeat for Haley in what is likely to be one of her final major actions as the US envoy.
Resolutions at the United Nations can carry political weight but are non-binding.More news: Former Attorney General William Barr contender for old job
"This resolution was really just an attempt to weaponise the United Nations against the Palestinian people, against their legitimate rights", he told Al Jazeera.
"This is a very important achievement for the US and Israel".
A number of States explained their reasons for voting against the resolution.
Israel and Hamas have gone to war three times.
She stressed that Hamas' charter "openly calls for the destruction of Israel" and cited a variety of "barbaric terrorist tactics" it has used including suicide bombers and thousands of rockets, flaming kites and balloons. Israeli Prime Minister Benjamin Netanyahu commended those that voted in favor.More news: Wall Street losses deepen on growth, trade worries
Diplomats from nine Arab countries were sent letters by Jason Greenblatt, the White House envoy who is working with Jared Kushner, Trump's son-in-law and adviser, on the administration's peace proposal.
Palestinian President Mahmoud Abbas, whose Fatah party is locked in a bitter decade-long split with Hamas, also welcomed the resolution's defeat saying: "The Palestinian presidency will not allow for the condemnation of the national Palestinian struggle".
"The UN has a chance to condemn Hamas for the first time", Haley tweeted Thursday. The fact that a majority backed it, though insufficient for the resolution to pass, was a "very important achievement for the United States and Israel", he wrote.More news: Jose Mourinho won't turn to £52million Fred until Manchester United can defend