Shortly after departing this southwestern German city on a Paris-bound train, a mysterious foreigner was pulled aside by police at the French border. The passenger claimed to be Palestinian, but carried no identification. He wouldn't say where he was going, or why.

Assuming they had caught an illegal immigrant looking for a better life in Europe, German authorities jailed the Arabic-speaking man in June 1999 and prepared to deport him. But they were unable to confirm his identity or figure out where to send him, so they moved him to a loosely supervised asylum camp for undocumented immigrants. Officials there paid little attention when he vanished two weeks before the Sept. 11, 2001, terrorist attacks in the United States.

The man who would later be code-named "Mohamed the Egyptian" by his Islamic radical friends resumed his illegal travels across Europe in 2001, taking advantage of the continent's open borders to move freely among Germany, Spain, France, Italy and possibly other countries.

Over the next three years, investigators say, he recruited volunteers for suicide missions, frequented fundamentalist mosques and played a key role in planning the biggest terror attack on European soil, the train bombings in Madrid on March 11 this year.

All along, Mohamed -- whose legal name is Rabei Osman Sayed Ahmed -- was able to dodge police and counterterrorism officials in at least three countries. They repeatedly put him on watch lists under a variety of names, but failed to figure out what he was up to, according to interviews with European investigators and a review of court and immigration documents.

"I know who they are, but they don't know who I am," the former Egyptian army officer said to a friend in Milan this past June, shortly before he was arrested by Italian police, who had been recording his conversations. "You confuse them, they won't know where you came from. . . . You're clandestine, but you move around with no problem."

The case highlights Europe's weakest defense in its fight against terrorism: As the continent removes internal barriers to trade and travel, Islamic militants find it easier to move around undetected. When they do attract notice, cell members can often stay a step ahead of the law by changing their names or slipping across borders, aided by long-standing bureaucratic and legal obstacles that prevent European counterterrorism officials from working together more closely.

"They are able to exploit the weaknesses that exist in our system," said Joerg Ziercke, president of the Bundeskriminalamt, Germany's federal law-enforcement agency. "They change routes, go across borders. We must close the gaps that we have in our information systems, and we must ensure that terrorists do not use one country as a haven while they are acting in another country."

European leaders have moved to address the vulnerabilities with such measures as common legal standards that make it easier to issue arrest warrants and extradition orders across the continent. They strengthened the cross-border police agency Europol. But many reforms remain unimplemented and many officials retain their long-standing reluctance to share sensitive information with neighboring countries.

For instance, nine years after a bomb went off in a Paris Metro station, killing seven people, French officials are still trying to extradite a prime suspect in the case, Rachid Ramda, who was arrested in Britain. His case remains tied up in the British court system.

Another breakdown in cooperation surfaced last month, when Spanish police said the ringleader of a cell suspected of plotting to blow up the Supreme Court building in Madrid was being held in a Swiss jail. At first, Swiss authorities denied they had custody of the suspect, Mohamed Achraf, but then acknowledged they did.

Swiss intelligence officials later said they had suspected Achraf of ties to Islamic radicals in Spain but didn't notify Swiss police or the Spanish government. Swiss Justice Minister Christoph Blocher blamed the mix-up on "an information breakdown."

Antonio Vitorino, former European commissioner for justice and home affairs, called the Madrid bombings "a wake-up call" that underscores the need to eliminate old rivalries among the many intelligence and law-enforcement agencies in Europe that fight terrorism.

"We cannot fix this overnight," Vitorino said to group of journalists at a dinner in Brussels last summer, shortly before leaving office. "The sharing of intelligence among member states is still far from desirable. . . . We Europeans are all equally targeted by the terrorist threat, and we all should be equally involved in fighting it."

A Natural Leader

The asylum camp in Lebach, Germany, has enough cinder-block apartments to house about 1,500 immigrants. They are mainly North Africans, Turks and Palestinians. Most stay a few months as they wait for German authorities to decide whether they can remain in the country for the long term.

On Sept. 13, 2000, a man calling himself Mohamed Abdul Hadi Fayad arrived at the camp after spending a year in jail and quickly assumed a leadership role among the residents. He presented their grievances to camp authorities. He spoke Arabic, English and Spanish, which made him useful as an interpreter. He also put together a makeshift mosque and led prayers during Ramadan.

"He called himself 'the Imam,' " recalled Barbara Paulus, a case worker at the camp in Lebach, a town of about 22,000 near the regional capital of Saarbruecken. "We didn't have any problems with him. The others respected him. He reported their problems and talked to us on their behalf."

Fayad was an anonymous foreigner who had been arrested a year earlier on his way to Paris. Soon after the arrest, he requested asylum. Though he had no papers, he identified himself as a stateless Palestinian who had been living in Lebanon. He said he arrived in Europe in April 1999 on a flight to Frankfurt and had been staying with a friend there.

The German government usually grants asylum as a matter of policy to Palestinians, but officials were unable to verify Fayad's story. Lebanese and Palestinian authorities said they could not confirm his identity and suspected he might be North African, according to a German law-enforcement official involved in the case.

Immigration officials denied Fayad's asylum request. But Germany could not deport him because officials didn't know where to send him. That situation is common in Germany, where about one in 20 asylum seekers is unable to verify the claimed nationality.

With his case in limbo, Fayad remained at the Lebach camp for almost a year. Residents are forbidden from leaving the local area, but they are not confined or closely monitored. As a practical matter, camp officials say, there is little they can do to make sure people stay.

So it didn't strike anyone as unusual when Fayad vanished. He was last seen in the camp on Aug. 29, 2001, when he came to the main office to pick up his twice-weekly food rations. Three weeks later, immigration officials notified the Lebach town hall that Fayad was no longer a resident and crossed his name off their case list.

"Each month, a lot of people disappear here," Paulus, the case worker, said. "I don't know how they do it, but each month we have to close a lot of files."

Always on the Move

Investigators have since established that Fayad had left the camp before, traveling across Europe under a variety of identities and passports.

In January 2001, he was seen with Islamic radicals in Madrid, police reported. Six months later, he applied for a residency permit in the Spanish capital under the name Rabei Osman el Sayed Ahmed, producing an Egyptian passport as proof of identity, according to a German law-enforcement official involved in the case.

On Sept. 6, 2001, a few days after he left Germany for good, he visited the Egyptian Embassy in Madrid and applied for a duplicate passport, saying he had lost his old one, the official said. That is a common trick in producing false identity documents -- the old passport is altered and given to someone else.

Soon after the visit, Ahmed attracted renewed attention in Germany and Spain, but for different reasons.

In the aftermath of the Sept. 11 attacks, German authorities investigated thousands of fundamentalist Muslims in the country to determine if any had ties to the Hamburg cell that planned the hijackings.

As part of this sweep, they re-examined the case of the stateless Palestinian who called himself Mohamed Abdul Hadi Fayad, prompted by people in the Lebach camp who noted he had disappeared a few days before Sept. 11 and seemed extreme in his religious beliefs. Investigators later determined he was not connected to the attacks, German officials said.

Meanwhile, in Madrid, Spanish counter-terrorism officials opened a separate investigation into Ahmed in December 2001 after they noticed that he was in frequent contact with members of a suspected cell of Islamic radicals, court papers show. One month later, Spanish investigators notified German law-enforcement officials that they had Ahmed under surveillance and requested information about his background, according to reports compiled by German diplomats in Madrid.

While Spanish police kept an eye on Ahmed, he worked as a painter in Madrid and married a Tunisian woman, according to investigators and a former roommate. He was apparently aware that he was being monitored and tried to keep low.

In a later conversation taped by Italian investigators, Ahmed told a friend that he spent years planning the Madrid attacks and had to be very cautious.

"In Spain I used different nationalities: Jordan, Egyptian, Palestinian, Syrian," he said. "Until my friends said it was enough -- I should be careful or I'll get caught . . . After 9/11, I was forced to move everything from Spain to Paris, because in Spain, there was a lot of movement from the secret service."

Keeping a Low Profile

Ahmed left Madrid for Paris in February 2003. French investigators said he spent five months there, again working as a painter and frequenting a mosque in an immigrant neighborhood. How often he went is unclear. A cleric at the mosque, a two-story beige building with bars on the windows, said he didn't recall seeing Ahmed. "I've been working here for 15 years, but I never knew him," said Ahmed Abou Hachem.

Few other details have emerged about Ahmed's stay in France. But while he was in Paris, he again attracted fresh interest in a neighboring country.

In April 2003, German prosecutors opened an investigation into his activities. Frauke-Katrin Scheuten, a spokeswoman for the German prosecutor's office, said the case remained open but declined to say what prompted it.

Ahmed returned to Madrid from Paris in July 2003. Four months later, Spanish police issued a report warning that they were investigating "the structure of a possible al Qaeda cell in Spain" headed by Ahmed, and that the cell had "links to other European countries." It is unclear if the report was shared with other European countries. One month after the warning, Ahmed moved on, this time to Italy.

Authorities Close In

In Milan, Ahmed sought work again as a painter and shared apartments with other Egyptian immigrants, moving frequently. He told roommates he was feuding with his wife in Spain and was worried she would report him to authorities, court papers show.

Italian authorities were not aware of his presence until April, five months after he arrived, when they were contacted by Spanish officials.

The Madrid commuter train bombings, which killed 191 people and injured thousands, touched off a furious investigation by Spanish authorities. The probe turned up Ahmed's cell phone number in the electronic address books of two suicide bombers and another suspect.

What followed was a rare case of successful cross-border coordination. Investigators traced the number and determined the phone was being used in Italy. They informed Italian authorities, who placed Ahmed under surveillance and bugged his phone and apartment in Milan.

According to transcripts of the wiretaps contained in an arrest warrant affidavit, Ahmed bragged to a roommate that "I was the leader of Madrid," adding that "the Madrid bombings were my project, and those who died as martyrs there were my beloved friends."

Italian police arrested him June 9, after hearing him discuss plans for another attack, possibly a suicide assault in Belgium, Italian officials said. In a computer in his apartment, they found photos of suitcase bombs similar to ones used in the Madrid attacks.

Investigators say there is still a lot they don't know about Ahmed; for instance, does he take orders from an international terrorist group and how did he come to Europe in the first place? They also disagree on whether he directed the Madrid attacks as he claimed in the wiretaps or if he was inflating his role.

In court papers, Spanish and Italian prosecutors charged that Ahmed was the "organizer of the terrorist group responsible for the attacks in Madrid" and also accused him of being the "coordinator of terrorist cells operating in various European countries," including Belgium, France and Spain.

Armando Spataro, an Italian prosecutor and chief of the anti-terrorism investigative unit in Milan, said investigators were convinced Ahmed was a key figure in Islamic radical circles. "We know he was important because he was the one who coordinated all the communications," Spataro said. "Only an important figure could have been able to move as much as he did and keep in contact with all these people."

Investigators said Ahmed hadn't talked since his arrest. One of his Italian lawyers, Viviana Bossi, said that he "denies any responsibility regarding all the charges."

He remains in jail in Milan, where he is fighting attempts to extradite him to Spain.

Special correspondents Sarah Delaney and Shannon Smiley contributed to this report.

"Mohamed the Egyptian" Italian police display photographs of Rabei Osman Sayed Ahmed, left, also known as "Mohamed the Egyptian," and another unidentified man.Victims of the March 11 train bombings, which killed 191 people and injured thousands, are tended by rescue workers after one of a series of explosions. European authorities believe Ahmed played a key role in planning the attacks.