A man who opened fire on a U.S. Border Patrol agent in a marked patrol vehicle near the U.S.-Mexico border had been deported and was living in Mexico in the months prior to the shooting, officials said Monday.

The agent's vehicle was parked within 50 feet of the border near the San Ysidro Port of Entry after 2:15 a.m. Sunday when several bullets struck the driver's side of the vehicle.

The agent, who was on duty at the time, was not hurt and immediately drove to a safer location.

An initial inspection found several bullet holes on the driver's side of the vehicle consistent with being shot at multiple times, according to U.S. Customs and Border Protection.

The shooting appeared to have originated from the Mexico side of the border and authorities there were immediately contacted, the agency said.

"This was a clear attempt to try to murder one of our Border Patrol agents," Border Patrol Agent Vincent Pirro said. "Multiple rounds hit his vehicle."

Mexican authorities initially took two suspects into custody and one of them was found with a handgun, the CBP said. The other person was released.

The armed suspect had been living in the U.S. before being deported to Mexico, according to officials with the police department in Tijuana. Tijuana police identified him as Sergio N., also known by his alias "El Checo."

The man had been living in Tijuana for approximately six months, police said.

He has a criminal record that includes human smuggling, officials said.

The FBI is working with Mexican authorities and the U.S. Attorney's Office as they investigate the incident.

The Border Patrol agent involved has 22 years of service with the agency. Agent Pirro told NBC 7 that since 2017, 80 Border Patrol agents have been injured. "That's with rocks -- they try to attack with knives, their fists," he said.

The location of the shooting was more than one mile west of the San Ysidro border crossing and immediately north of the U.S.-Mexico international boundary, the agency said.

The FBI is handling the investigation. Federal agents did not confirm if the man accused of firing at the agent would be charged, but did say they are coordinating with the U.S. Attorney's Office and officials in Tijuana.