Libya, backed by Egypt, had asked for an end to the arms embargo to allow the embattled government to build up its army and take on groups such as ISIS.
But the resolution drafted by Jordan kept the four-year arms embargo in place while opening the door to exemptions on a case-by-case basis.
The measure called on a Security Council committee to “consider expeditiously” requests for arms purchases from Libya.
Earlier this month, eight Security Council members led by Spain froze indefinitely a request from Libya for purchases of fighter jets, attack helicopters, tanks and munitions.
The refusal to allow the arms purchases followed a letter from a U.N. panel of experts warning that the arms shipments could fall into the wrong hands.
Libya is awash in weapons and considered a major arms trafficking hub for North Africa, as powerful militias battle for control of key cities and the country's oil riches.
The resolution expressed “grave concern” about the growing presence of ISIS fighters in Libya and of groups that have pledged allegiance to ISIS along with those aligned with al-Qaeda.
The measure threatened sanctions against individuals and groups that support the violent extremists through financing, recruitment or through the Internet and social media.
The 15-member council also voted to extend the mandate of the U.N. political mission in Libya until September with a view to helping the country's warring sides reach a power-sharing deal.
The United Nations is leading negotiations between Libya's rival sides on forming a unity government that could turn its full attention to confronting the threat from extremist groups.
Libyan Ambassador Ibrahim Dabbashi said the U.N.-brokered talks had yielded “very significant progress” and that “hope has become brighter” for a political solution.
Libya has been in turmoil since the 2011 overthrow of longtime dictator Muammar Qaddafi in a NATO-backed uprising.