The ministers endorsed a draft declaration that called counterterrorism "a key element of political dialogue" with other countries, and officials said aid and trade could be affected if the fight against terrorism was considered insufficient.
The declaration says the EU would add counterterrorism concerns into "all relevant external assistance programs."
Irish Foreign Minister Brian Cowen, whose country holds the EU presidency, said the "comprehensive anti-terrorist package ... ensuring the safety of citizens" would be presented to a summit of EU leaders on Thursday and Friday.
"The events of March 11 have rightly led us to redouble our efforts" against terrorism, he told reporters, referring to thethat killed 202 people.
The EU has already tried to use its economic leverage to bring nations into line. With Iran, it has suspended free-trade talks until Tehran comes clean on, while an aid-and-trade deal with Syria hinges on .
British Foreign Secretary Jack Straw said the ministers set a June 30 deadline for all EU nations to enact a series of anti-terrorist laws, most notably the European arrest warrant legislation that five nations must still enact.
"The problem for the European Union is that we can only go at the pace of the slowest," he said. "Therefore, there is a special responsibility on the countries which have failed so far implementing measures to get moving."
The foreign ministers also approved measures to commit member states to help one another in case of a terrorist attack and backed the creation of an EU anti-terrorism coordinator to improve cooperation.
The ministers also backed plans to enhance cooperation among police and intelligence services across the continent.
The declaration commits the 25 current and soon-to-be EU members to "act jointly in a spirit of solidarity if one ... is the victim of a terrorist attack." It includes a pledge to mobilize "all the instruments at their disposal, including military resources," to prevent attacks or assist one another in the aftermath.
EU foreign policy chief Javier Solana called for more solidarity.
"In the fight against terrorism, the national interests are not the leading element because every country is in the same situation," said Solana. "International and European cooperation is absolutely fundamental."
The summit opening Thursday had been scheduled to focus on the economy until the Madrid attacks pushed terrorism to the top of the EU's agenda.
Calls from Belgium and Austria for a centralized European intelligence agency found little backing because of concerns it could increase bureaucracy and the risk of intelligence leaks.
France and Britain are against sharing sensitive military and political intelligence among all of the 25 member states.
"It is a very delicate matter to deal with," said French Foreign Minister Dominique de Villepin. "We have to be very careful the way we handle it. Widening the circle (of information sharing) is something we should do very carefully."
Straw agreed, saying Britain would share "intelligence on a bilateral basis."
"It requires a very high level of confidence and trust when you are going to do that," he said.
Ministers also discussed prospects for reopening talks on a first-ever EU constitution. Leaders will decide on that at the summit.
By Constant Brand