Media playback is unsupported on your device Media caption Watch: Foreign Secretary William Hague: 'Quiet diplomacy is always going on'

The UK is "absolutely in line" with the US in preparing plans for a possible "no-fly zone" to be imposed over Libya, William Hague has said.

The foreign secretary told the BBC the international community agreed these were only "contingency" arrangements.

US Defence Secretary Robert Gates has warned against "loose talk" about steps that could amount to an act of war.

But Mr Hague said the countries had "the same attitude" to no-fly zones and possible military intervention.

Libya's government has faced a widespread revolt against its rule and the UN believes hundreds of people have died in the unrest.

UK Prime Minister David Cameron said on Monday that imposing a no-fly zone was being considered if Muammar Gaddafi's regime used air strikes on his own people in an effort to break the will of rebels.

'Atrocities'

He added on Wednesday that "all eventualities" were being looked at in case this happened.

None of these are pain-free options William Hague

But Mr Gates said a no-fly zone - banning the Libyan military from taking to the air - could be created only after "an attack on Libya" to destroy the country's aerial defences.

In an interview with BBC political editor Nick Robinson, Mr Hague said any such action in Libya "would have to be legal".

He added: "It would have to have widespread international support, including support from the Arab world. So it would not be the Western world trying to impose its will in any way.

"It would be the international community saying we have a responsibility to protect people and we are not going to allow atrocities to take place and, of course, the Libyan people must determine their own future."

Speaking about the UK's relationship with the US, France and Germany, Mr Hague said: "We have supported the same policies. We have all supported the same resolution at the [United Nations] Security Council and we all have the same attitude to no-fly zones and military intervention."

The British government should maintain a considered and consistent position and avoid being seen to talk up options one day before talking them down the next Douglas Alexander, Shadow foreign secretary

Asked what courses of action could be taken if the Gaddafi regime used air strikes, the foreign secretary said: "None of these are pain-free options, but clearly we are not proposing a no-fly zone at the moment - simply the planning on that...

"But, as the prime minister has said, if people were being attacked in huge numbers, then it's unlikely the world would just want to stand idly by. But we have to do the contingency planning. The United States is doing that with us. I think that's the sensible and precautionary thing to do."

Earlier the prime minister's spokesman said the UK's position had not changed and there were "a number of ways" in which a no-fly zone could be implemented if the situation arose, but the UK was focused on diplomatic efforts with international partners.

Asked if Mr Cameron was concerned at the Foreign Office's failure to foresee the "Arab spring", the spokesman said: "It is a reasonable thing to say on recent events in that region that there were not lots of people who predicted those events.

"What happens next is also very uncertain. We are dealing with a very uncertain situation."

For Labour, shadow foreign secretary Douglas Alexander said Mr Gates's "careful and considered" comments were a "powerful reminder of the strategic importance of the whole international community maintaining unified and sustained pressure on the regime in Tripoli".

"The British government should maintain a considered and consistent position and avoid being seen to talk up options one day before talking them down the next.

"It is right that all options should be on the table when considering the plight of the Libyan people but, as Secretary Gates's remarks emphasise, these are not decisions that should be entered into lightly."

'United' cabinet

The Times newspaper has reported differences between Education Secretary Michael Gove and Mr Hague over Libya at a cabinet meeting on Tuesday.

It quoted unnamed witnesses as saying that Mr Hague argued for a more restrained approach, while Mr Gove is reported to have said Britain must be tougher in facing down dictators and supporting freedom around the world, and attacked the Foreign Office's failure to foresee the crisis in the Arab world.

But Mr Hague said the cabinet was "united" and that he thought he had been described as a "dove" before.

Quizzed about the alleged row on Sky News, Mr Gove said: "When it comes to questions like Libya and foreign policy, the foreign secretary is the expert. I am interested in what happens abroad, but primarily because it helps me bring better education policies to this country."