A man shoots at a U.S. consular official in his car in Guadalajara, Mexico, in this image taken from Jan. 6 security video footage. (U.S. Embassy in Mexico via Reuters)

An American who allegedly shot and wounded a U.S. diplomat in Mexico has been charged in federal court in Virginia.

Zia Zafar, 31, of Chino Hills, Calif., was arraigned Tuesday afternoon in U.S. District Court in Alexandria on a charge of attempted murder of an internationally protected person.

Christopher Ashcraft, vice consul at the U.S. Consulate in Guadalajara, was leaving a gym there Friday evening when he was shot by Zafar, according to prosecutors. Authorities did not offer any possible motive in the shooting, and it was unclear if Zafar and Ashcraft were known to each other.

The bald, slim suspect said little at a brief hearing, telling a judge only that he understood the charge against him and could not afford a lawyer. He will be jailed until Friday, when prosecutors will argue for prolonged detention.

Security video from the night of the attack shows the gunman, wearing blue scrubs, dark sunglasses and what looks like a wig, appearing to follow Ashcraft as he exits the gym and pays for his parking. The man is later seen pacing, with his right hand in his pocket. As Ashcraft’s car pulls up the exit ramp, the man fires into the vehicle and then runs. Ashcraft was hit in the chest.

Mexican officials said Zafar arrived in Guadalajara from Phoenix in late November. A spokesman at the Autonomous University of Guadalajara has said Zafar was enrolled there.

Ashcraft is in his first posting with the State Department, according to a friend who spoke to The Washington Post on the condition of anonymity.

According to the friend, the assailant reportedly asked for Ashcraft by name at the gym’s reception area.

Ashcraft “has no idea what happened,” said the friend, who has been in contact with Ashcraft since the shooting. “But it wasn’t random.”

In an interview from a hospital, where he remains in stable condition, Ashcraft told FBI agents that when he left the gym that evening, he sensed that a person was waiting for him, according to court documents. He walked to a kiosk to pay for his parking.

When he turned to walk to his car, he said, he noticed the person was following him, so he walked to a populated part of the garage. Seeing that the person was no longer following him, Ashcraft said he got into his car and drove toward the garage exit.

According to an affidavit from FBI agent David J. DiMarco, Zafar was identified a day later by another security video, showing him making a purchase at a Starbucks about an hour before the shooting. Law enforcement got a copy of his receipt, signed with the name ­“Zafar Zia.”

Officials say Zafar entered Mexico on a student visa and holds a U.S. passport. He has a California driver’s license and a Honda Civic with California plates. The Post was unable to reach any of his family members in the United States.

Mexican law enforcement searched Zafar’s local residence, recovering a pistol, a pair of sunglasses and a wig, according to court documents.

The shooting alarmed the top levels of the Mexican government. Foreign Minister Luis Videgaray was in contact with the U.S. ambassador, Roberta Jacobson, and the hospitalized Ashcraft was under guard in Guadalajara, according to Mexican officials familiar with the case.

“This was a heinous thing,” one Mexican official said.

The office of Ashcraft’s father, Larry Ashcraft, a leader of the Salvation Army in Cincinnati, referred questions about his son to the State Department.

In a statement after Zafar’s arrest, Secretary of State John F. Kerry thanked the Mexican government “for the prompt and decisive arrest of a suspect in the outrageous attack on one of our colleagues.”

If convicted, Zafar could go to prison for up to 20 years.

Partlow reported from Mexico City. Gabriela Martinez in Mexico City contributed to this report.