The action came as the Libyan leader was poised to make a final push against rebels holding out in Bengazhi, Libya's second largest city.
The vote in the 15-member council was 10-0 with five abstentions, including Russia and China.
The United States, France and Britain had pushed for speedy approval.
French Prime Minister Francois Fillon said if the resolution was approved, France would support military action against Gadhafi within hours. The U.S. said it was preparing for action. Several Arab nations were expected to provide backup.
Gadhafi vowed to launch a final assault on Benghazi and crush the rebellion as his forces advanced toward the city and warplanes bombed its airport Thursday.
Gadhafi said in an interview broadcast Thursday on Portuguese public broadcaster Radiotelevisao Portuguesa that he rejected any U.N. threats of action.
"The U.N. Security Council has no mandate," Gadhafi said. "We don't acknowledge their resolutions."
He warned that any military action would be construed as "colonization without any justification" and would have "grave repercussions."
The text of the resolution calls on nations to "establish a ban on all flights in the airspace of the Libyan Arab Jamahiriya in order to help protect civilians."
It also authorizes U.N. member states to take "all necessary measures ... to protect civilians and civilian populated areas under threat of attack in the Libyan Arab Jamahiriya, including Benghazi, while excluding a foreign occupation force of any form on any part of Libyan territory."