CNN  — 

A US Border Patrol agent was shot Tuesday morning in southern Arizona near the border with Mexico, and several people in the area were taken into custody, federal authorities said.

The agent, an experienced medic, is in stable condition after he was airlifted to a hospital, said Rodolfo Karisch, the sector chief. The agent, who was not identified but is a 21-year-veteran, is in good spirits, Karisch said.

Karisch said an unknown number of attackers fired at the agent, including one who was shooting from “close proximity.”

Several people were arrested for immigration violations, but it is unknown whether they were involved in the shooting.

The agent was on foot looking at some sensor equipment that had been activated and then was attacked in an area south of Arivaca, which is about 10 miles from the border with Mexico.

He was alone when he was attacked and managed to get back to his vehicle, where he called for help and did self-care on his wounds.

Authorities didn’t say in what part of the body he was shot, but said he had on a ballistic vest.

The shooting occurred on part of a 50,000-acre ranch, said Jim Chilton, owner of the vast property. He said Mexican drug cartels smuggle drugs and people through the area, and there is only a cattle fence covering 25 miles along the Arizona-Mexico border that touches his ranch. The closest Border Patrol station is 80 miles away, according to Chilton, and cartel lookouts can easily spot agents approaching.

Chilton said the shooting took place 6 or 7 miles from his ranch house.

The agency said it and the FBI are investigating the shooting.

CNN’s Jason Hanna contributed to this report.