Updated

Federal prosecutors laid out their case against a Muslim cleric from Pakistan on Wednesday, alleging that he was involved in a northern California terror network with links to terror leader Usama bin Laden (search) and that his group was planning to set up a camp to train followers to kill Americans.

Shabbir Ahmed (search), 39, is only charged with overstaying his visa while he was heading a mosque in Lodi, a town of 62,000 about 30 miles south of Sacramento. The allegation about the terrorist camp came from an FBI agent's testimony during the immigration hearing.

"Do I believe he is planning a terror attack?" FBI agent Gary Schaaf said. "That's some of the information that has been provided to us."

He testified that Ahmed and others were in the fledgling stages of opening a terrorism training camp in Lodi.

Schaaf did not say what type of terrorist attacks were planned, but he said Ahmed was acting as an intermediary for bin Laden and other terrorists.

Arguing to keep Ahmed in custody, federal prosecutors used a "flow chart" showing him to be just a few rungs down the ladder from bin Laden.

According to the FBI, bin Laden would give orders to Taliban (search) commander, Jala Luddin Hoqqani, who would pass them on to Muhammed Adil Khan (search), another Lodi imam who is also in custody on visa violations.

Adil Khan would then tell Ahmed, his protege and head of the Lodi mosque, whose membership included Umer Hayat and his son Hamid Hayat, Pakistanis who face terror-related charges.

Federal government officials believe the group's long-term goal was to indoctrinate local Muslims in radical Islam in a kind of American "madrassa,” similar to the religious school in Pakistan where Ahmed and Adil Khan once worked.

Immigration Judge Anthony Murry (search) declined to offer Ahmed bail as he fights the immigration charge. "I am compelled to find you are both a flight risk and a danger to the community," he said.

Ahmed's lawyer said his client was not a terrorist and that the judge blindly took the word of the FBI agent.

"Immigration judges don't want to second-guess the government," defense lawyer Saad Ahmad said.

The judge set an Oct. 24 hearing in which Ahmed can challenge his detention and immigration charge.

Ahmed was one of five men connected to the mosque arrested in June. The testimony was the first time federal agents have linked the five Lodi detainees.

Hamid Hayat (search), 22, told interrogators he was to receive orders from Ahmed, Schaaf testified.

Hayat is charged with lying to the FBI about attending a terrorism camp in Pakistan in 2003 and 2004. His father is charged with lying when he denied his son had attended such a camp.

The Associated Press contributed to this report.