British and French military aircraft are preparing to protect the Libyan rebel stronghold of Benghazi after the UN security council voted in favour of a no-fly zone and air strikes against Muammar Gaddafi's forces.

With Gaddafi's troops closing in on Benghazi, the French prime minister, François Fillon, said "time is of the essence" and that France would support military action within hours of the vote.

But a US official was more cautious, warning against expectations of imminent action. French planes will operate from bases on its Mediterranean coast. Several Arab countries have promised to join the operation. The US backed the resolution, a complete turnaround after weeks of resisting no-fly zone proposals, but has not yet said what role it would play in military action.

The 15-member security council voted in favour of a resolution authorising all necessary measures to protect civilians under threat of attack, in particular Benghazi. Ten members voted in favour, with five abstaining, including China, Russia and Germany. The resolution ruled out putting troops on the ground.

Rebels in Benghazi celebrated in the streets after the no-fly vote was announced. Gaddafi called the vote "flagrant colonisation" and warned of dire consequences. "This is craziness, madness, arrogance," he told the Portuguese TV channel. RTP. "If the world gets crazy with us, we will get crazy too. We will respond."

In a chilling message earlier, he also threatened that no mercy would be shown to residents of Benghazi who resisted him. Earlier, his regime issued a strong warning that it would target all maritime traffic in the Mediterranean if it is targeted by foreign forces. In a statement broadcast on Libyan television, the defence ministry said: "Any foreign military act against Libya will expose all air and maritime traffic in the Mediterranean Sea to danger and civilian and military [facilities] will become targets of Libya's counterattack."

Residents and a rebel spokesman reported three air strikes on the outskirts of Benghazi on Thursday, including at the airport, and another air raid further south. There was also heavy fighting in residential areas of nearby Ajdabiya, where around 30 people were killed, the TV station al-Arabiya reported.

The UN resolution was co-sponsored by Britain, France and Lebanon, with the US heavily involved in the drafting. A security council source said the resolution would impose a no-fly zone over Libya but that was no longer enough. "The resolution authorises air strikes against tank columns advancing on Benghazi or engaging naval ships bombarding Benghazi," he said.

Nato would have to meet before committing any forces.

The US secretary of state, Hillary Clinton, who is on a visit to Tunisia, said a no-fly zone would "require certain actions taken to protect the planes and the pilots, including bombing targets like the Libyan defence systems".

Speaking outside the UN security council in New York, Alain Juppé, the French foreign minister, said there was "reason to anticipate that some Arab countries will participate". The Wall Street Journal reported that Egypt, with the knowledge of the US, was already sending weapons to the rebels.

Germany, which opposes a no-fly zone, remains sceptical about the value of military action. In an interview with the Guardian, its foreign minister, Guido Westerwelle, said Berlin remained strongly opposed to any military intervention in Libya or the use of air strikes against Gaddafi.

Westerwelle warned that the consequences of western military intervention were 'unpredictable' and could affect freedom movements in the Arab world. "Your own instinct is to say 'We have to do something'. But military intervention is to take part in a civil war that could go on for a long time. Germany has a strong friendship with our European partners, but we won't take part in any military operation and I will not send German troops to Libya," he said.

Instead, Westerwelle said there were non-force options that could still be used against Libya, including 'targeted sanctions, political pressure and international isolation."

"Considering alternatives to military engagement is not the same as doing nothing,' he said. He declined to say how Germany would vote ahead of this evening's vote in the UN security council.William Hague, the foreign secretary, said the resolution was necessary "to avoid greater bloodshed and to try to stop what is happening in terms of attacks on civilians".

The British and EU criteria for a no-fly zone – a demonstrable need, a clear legal basis and broad regional support – had all been met, he added.

"This places a responsibility on members of the United Nations and that is a responsibility to which the United Kingdom will now respond," Hague said at the Foreign Office shortly before heading for talks in Downing Street with the prime minister around 11pm last night.

David Cameron and Barack Obama discussed the operation in a phone call. Ministers were holding talks late into the night in Downing Street to discuss the next steps.

Sir Malcolm Rifkind, the former foreign secretary, told the BBC: "Without action of this kind, Benghazi would have been a bloodbath. By the standards of the last 20 years, this is a remarkable vote. This is a tremendous morale booster for Libyans, not just in Benghazi."

After weeks of stalling by the US, Washington backed the resolution after the Arab League at the weekend joined the calls for a no-fly zone.

The Obama administration had been divided between Clinton, who favoured a no-fly zone, and the defence secretary, Robert Gates. Gates, although opposed to the no-fly zone, redeployed US naval vessels close to the Libyan coast and told the president that the military was capable of fighting on a third front.

Three US senators, representing a cross-section of political opinion, John Kerry, John McCain and Joe Lieberman, issued a joint statement welcoming the vote: "With Gaddafi's forces moving towards Benghazi, we must immediately work with our friends in the Arab League and in Nato to enforce this resolution and turn the tide before it is too late."