An American lawyer who was arrested two weeks ago in connection with the terror attacks in Spain was set free Thursday after evidence pointed to another suspect in the deadly train bombings.

Brandon Mayfield (search), 37, was released soon after Spanish officials said fingerprints found on a bag near the bombing site were that of an Algerian. U.S. authorities had previously said the prints were Mayfield's. The bag contained detonators similar to those used in the March 11 blasts, which killed 191 people and injured 2,000 others.

"I want to thank my family and friends who were supporting me through what I will call a harrowing ordeal," Mayfield, a convert to Islam, said as he walked out the federal courthouse in Portland, grasping his wife's hand and holding a Quran (search) and a Muslim prayer rug.

In Arabic and then in English, Mayfield recited the Muslim prayer: "God is great. There is no God but God."

His three children, ages 10, 12 and 15, rushed up behind him, and his wife's eyes filled with tears. The family has insisted Mayfield is innocent, saying he has not been out of the country for at least a decade.

His mother, Avnell Mayfield, said she hugged her son when he arrived at his suburban Portland home. "I'm just elated," she said in a telephone interview. "He's much taller than I remember him being."

Mayfield was released before his children could finish crocheting a pair of yellow and tan socks for him. "Dad, you got out sooner then we thought," his 10-year-old said, according to Avnell Mayfield.

Samer Horani, a board member of the Islamic Center of Portland (search), called Mayfield's arrest a stark example of the FBI's profiling of Muslims. "Ethnicity doesn't matter. If you are Muslim you are suspect," he said.

Through relatives, Mayfield said he could not comment because of a gag order.

Mayfield, a former Army lieutenant who ran a small, struggling Portland law firm, was arrested May 6 as a material witness and was never charged. It is not clear whether the investigation against him has been dropped.

FBI spokeswoman Beth Anne Steele said she could not comment because "it is a pending grand jury matter." But she would not say whether the grand jury was weighing an indictment against Mayfield. Justice Department officials in Washington declined to comment on the case.

Senior law enforcement officials in Washington speaking on condition of anonymity had said the FBI had Mayfield's home under surveillance for weeks. When it became clear that news about him might leak, the Justice Department placed him in custody, the officials said.

Steve Wax, Mayfield's attorney, said a gag order issued by a federal judge remained in place, and he could not discuss details.

But he added: "The reality of this case is that some breaks in that secrecy -- some leaks -- have been quite harmful to Mr. Mayfield."

In Madrid late Thursday, authorities said the fingerprints found on the plastic bag belonged to an Algerian, Ouhnane Daoud. The bag was found in a van hours after the morning rush-hour blasts. The van had been left near the train station from which three of the four bombed trains had departed.

The bombings were blamed on Islamic militants with possible links to Al Qaeda.