The man was shot early Tuesday in a mountainous region east of the Otay Mesa crossing, Lt. Glenn Giannantonio said.
Police said two agents were tracking two men suspected of entering the United States illegally when one of them came across a third man, U-T San Diego reported. The third man ran away and one of the agents chased after him.
At one point the man allegedly began throwing rocks, striking the agent, despite repeated requests to stop, Giannantonio said.
A rock hit the agent in the head, the lieutenant said.
"Fearing that another rock strike to the head could kill or incapacitate him, the agent fired his duty pistol at least twice at the man, striking him," Giannantonio said.
The man died at the scene.
The agent, whose name wasn't reported, had minor injuries and was treated and released from a hospital. He was placed on administrative leave.