"The four men, of Spanish nationality and Moroccan origin, have a very similar profile to those who carried out the attacks in Paris," the interior ministry said in a statement.
Video released by the police showed around a dozen heavily-armed officers shining searchlights into windows before storming two houses in the narrow streets of Ceuta before dawn on Saturday.
Police found a gun, combat uniforms, Spanish car licence plates and machetes when they made the arrests.
"They are two pairs of brothers, highly radicalized and highly trained," Interior Minister Jorge Fernandez Diaz told reporters.
The brothers, as part of a network, carried out aggressive campaigns on Internet forums using Islamic State slogans to recruit people to fight in Syria and Iraq and carry out attacks in Western countries, the ministry said. Their activities are still under investigation.