A Virginia man whose lawyer bailed on his client after learning the defendant may have ties to terrorists was getting a new hearing and a new lawyer Thursday.

Agus Budiman had been charged with identification fraud for his assistance in helping another man unlawfully gain a Virginia driver's license. 

But when U.S. Attorney Greg English, appointed to defend Budiman,  heard FBI agent Jesus Gomez say that Budiman, an Indonesian native, has ties to Al Qaeda terrorists, including presumed Sept. 11 hijackings ringleader Mohammad Atta, English was so startled he told the judge he could no longer represent Budiman in good conscience. 

U.S. District Court Judge Theresa Buchanan allowed English to drop out and assigned a new judge for Budiman.

During testimony Monday in U.S. District Court, Gomez said Atta had confided his hatred of the United States to Budiman while Budiman helped Atta and another would-be hijacker, Ramsi Binalshibh, a Muslim cleric, move into a Hamburg, Germany apartment a few years ago. 

FBI Director Robert Mueller has identified Binalshibh as the "20th hijacker" who was supposed to be aboard United Airlines Flight 93, which crashed into a Pennsylvania field Sept. 11. 

According to Gomez, Binalshibh tried to use Budiman's residence to get a visa, but was unable to do so, which is why he was absent the day of the hijackings. 

English said he thought he was in court to represent Budiman on a routine fraud case unrelated to the hijackings. 

English immediately told the judge he was a former Army officer whose wife worked for the Department of the Army and had friends who were killed in the Pentagon when another hijacked plane crashed into it Sept. 11. Therefore, he said, he could no longer represent Budiman. 

In the affidavit submitted to the court on the fraud charges, Gomez makes no reference to Budiman's relationship to Atta or Binalshibh, but says Budiman was illegally working in the United States last April when his visitor visa had expired. 

Budiman had applied for a visa extension from the Immigration and Naturalization Service, but was denied after he admitted that he was working for a food-delivery service. 

The INS later arrested Budiman, but only a month after the FBI had questioned him. The FBI had learned that Mohammad Belfas, for whom Budiman co-signed a Virginia Department of Motor Vehicles residence document, was listed in federal documents as a contact name for terrorist leader Usama bin Laden. 

Gomez said nothing about Budiman's relationship to Atta and Binalshibh in his affidavit. The detention hearing was ended before he could make a clear distinction tying Budiman to Atta and the hijacking. 

The penalty for document fraud is up to 15 years in prison. Budiman is being held without bond. 

Fox News' Rita Cosby contributed to this report.