Spain's foreign minister has warned an international conference focusing on Libya that the country could slide into a civil war situation similar to what is happening in Syria.

Jose Manuel Garcia-Margallo said Wednesday there is still time to prevent extremists from controlling the country.

He is among those at a Madrid conference on the political crisis in Libya attended by officials from 16 nations, the United Nations and the Arab League.

U.N. special representative for Libya Bernadino Leon stressed the country needs an immediate cease-fire.

Libya has rival governments. One is recently elected and based in Tobruk, where it moved after Islamist militias took control of Tripoli and Libya's second-largest city, Benghazi. The previous Islamist-led parliament remains in Tripoli and is backed by the militias.