OAKLEAF, Fla. – A gunman ambushed a customs agent Tuesday afternoon, shooting him from behind before turning the gun on himself and taking his own life in the parking lot of a Publix shopping center in the Oakleaf area, Clay County deputies said.

The agent, who is a pilot for the U.S. Customs and Border Protection's Air and Marine Operations agency, was taken to a local hospital, where he underwent surgery for serious injuries and is expected to survive, deputies said.

Clay County Sheriff's Office Chief of Investigations Wayne McKinney said the shooting was reported about 3:11 p.m. in the Oakleaf Commons shopping center on Oakleaf Plantation Parkway, just west of Branan Field Chaffee Road.

McKinney said the customs pilot, whose name has not been released, left the Publix and was carrying groceries to his personal truck when an 18-year-old drove up from behind him, pulled out a small-caliber handgun and fired several shots as he passed the agent, who was struck in the abdomen.

It's unclear how many times the agent was hit, but he was caught completely off guard and did not return fire, McKinney said.

After the shooter fired at the agent, he continued driving down the parking lane and appeared to succumb to a self-inflicted gunshot wound, causing his car to then hit several vehicles in the parking lot, McKinney said.

The motive for the shooting remains unclear, but the agent was wearing a uniform, badge and shoulder holster, McKinney said. He added that there does not appear to have been any previous contact between the two men.

"If he was walking out with groceries, he's not in a tactical situation where he's planning or prepared to deal with a wanted person or any suspect," said Gil Smith, News4Jax crime and safety analyst.

McKinney said being the target of such a "heinous" crime is a danger for any law enforcement officer.

“It is disturbing. It is something that we live with each and every day, knowing that going out in our community there are individuals that would target us just for the badge we wear on our chest," McKinney said. "It is disturbing, but we're trying to keep our feelings out of it at this time and conduct the investigation to the utmost of our abilities."

McKinney said there are more than two dozen witnesses to the shooting, and some of them said the shooter was driving around the parking lot before the ambush.

Among those witnesses were workers from a nearby business, who told News4Jax that they were headed to lunch at the Publix when they heard four or five gunshots. They said the incident was surreal and that they stood in shock trying to process what they'd heard.

"I never thought something like this would happen over here," Darron Williams said. "It's just crazy to see it."

They said officers were on the scene within minutes and they never felt as if they were personally in danger. But shoppers coming out of the Publix store said they were still upset because the community is relatively quiet.

“I think it’s kind of sad," Rebecca Grimm said. "Like I was telling the kid inside, you can’t even go to the grocery store anymore."

One woman said she visits the Publix almost daily and never imagined there would be a deadly shooting outside.

“It’s very scary. It’s too close to home, but these things can happen anywhere," Kemberlee Beaty said. "There’s nothing you can really do to prepare yourself for that.”

The shooter had an active warrant out for his arrest on charges of selling drugs, McKinney said.

News4Jax has chosen not to identify the shooter because his name has not yet been released by investigators, but social media posts about the gunman led News4Jax to a home across the street from where the shooting took place. No one inside the home would talk, but neighbors said they recognized the person believed to be the shooter and his vehicle in a photo. One neighbor, who wished to remain anonymous, said deputies were at the home talking to someone.

"It was three cops and they had their weapons. They were talking to him for a minute, so I stood at my doorway, like, 'What's going on?'" the neighbor said. "Next thing you know, they went into the house."

The neighbor said she often saw the man believed to be the shooter and she noticed a lot of suspicious activity at the house.

"There's usually a lot of teenagers or adults in their early 20s stopping at the house and picking up packages," she said.

The agent continues to recover in the hospital.