The arrests took place in Cologne on Friday when a Somali and a German of Somali descent were escorted off a plane bound for the Dutch city Amsterdam.
German prosecutors on Saturday were granted arrest warrants for the two men by a local court. Chief prosecutor Fred Apostel said evidence provided by police showed the pair "were planning to carry out an attack in the near future."
Security sources said the pair had been under observation for months and were planning to travel via the Netherlands to a training camp for militants on the Pakistan-Afghan border.
A search of their apartment had turned up letters in which the two men, who are in their 20s, had declared their readiness to die in a jihad or holy war, the sources said.
Police apparently stepped in to prevent them from joining their comrades in the Islamic Jihad Union, (IJU), often described as a successor to the terrorist network al Qaeda.
Planning terrorist attacks?
German police are currently searching for two other militants who underwent training in the use of firearms and explosives at an IJU camp and are now believed to be back in Germany.
Police fear Eric Breininger, a 21-year-old German convert to Islam, and Houssain al-Malla, a 23-year-old Lebanese, might be planning terrorist attacks in Germany.
Breininger, who is from Saarland state in the west of the country, is reported to have recorded an Internet video in which he spoke of carrying out a suicide attack and supported jihad.
The two men were also believed to have been in contact with one of the three IJU adherents who were arrested in the Sauerland region in September 2007 on suspicion of plotting attacks against US targets.
Christian Democrat politician Wolfgang Bosbach called Saturday for tougher laws to deal with people who are schooled in terrorist training aboard and then return to Germany. Under current law staying at such camps is not an offense.
"We have to close this loophole," Bosbach said, pointing to the enormous cost of surveillance of the returnees.
Some experts believe there are up to 100 home-grown militants who have attended training camps aboard and returned to Germany to recruit new adherents.
Bavarian Interior Minister Joachim Hermann voiced the fear that the growing number of German converts to Islam could become radicalized.
"Young people who feel marginalized in society are susceptible to becoming Islamists," the conservative politician said. "The Breininger case is such an example."
Germany has so far managed to avoid al Qaeda-inspired attacks like the Madrid train bombings of March 2004 which left 191 dead or the suicide attacks on the London transport system 16 months later, which killed a total of 56 people.
In July 2006, an attempt to blow up two passenger trains in Germany with suitcase bombs failed because of a fault in the timing device. One of the perpetrators was jailed for 12 years by a court in Lebanon. Another accused is still on trial in Germany.
Earlier this week, three teenagers of Turkish descent were arrested in Cologne after luring two police officers into an ambush and firing blanks at them. The trio told prosecutors they planned to steal the officers' firearms and use them in attacks on Americans and other targets as part of a holy war for which they were prepared to die.
The group, aged 15-17, had apparently been watching Islamist hate videos before their assault on the police.
"The jihad has now become a pop phenomenon," the Tagesspiegel newspaper quoted one security source as saying. Dying as a martyr in the name of Allah could soon become the ultimate symbol of provocation for rebellious youth, he added.
US, EU ministers agree to cooperate
Interior ministers from the US and six European countries meanwhile called Saturday for greater cooperation to combat international terrorism. A common approach and an effective strategy to prevent terrorist attacks was necessary, German Interior Minister Wolfgang Schaeuble said after a day-long meeting in Bonn.
To achieve this goal, close cooperation with the United States was indispensable, Schaeuble said.
US Homeland Security Secretary Michael Chertoff was present at the gathering, along with Schaeuble and representatives from Britain, France, Italy, Spain and Poland.
The conference agreed that strategies needed to be developed in order to prevent young people from becoming radicalized, Schaeuble said.
The ministers discussed ways to stop the spread of hatred and instructions on how to carry out attacks via modern forms of communications technology such as the Internet. They agreed to set up a panel of experts to look into the legal framework for cross-border measures to access computer hard drives and other data storage equipment used by terrorist suspects.
Schaeuble said Germany remained a target for terrorists, but the security services were doing everything they could within the law to limit the danger and protect the country's citizens.