Mexican President Felipe Calderon on Wednesday condemned a Border Patrol agent's fatal shooting of a Mexican man who allegedly struck another agent with a nail-studded post. The union representing agents called the triggerman a hero.

The victim was shot once after he hit the agent in the head with the nail-studded piece of wood that was about 3 feet long and resembled a table leg, said San Diego police Lt. Ernie Herbert. He was about to throw a rock when the other agent fired.

The victim fell on the Mexican side of the fence near San Diego's San Ysidro border crossing, where he died Tuesday night, Herbert said.

Mexican authorities identified the victim as Jose Alfredo Yanez, 40, of Tijuana. Heriberto Garcia, the Baja California state human rights ombudsman, said Yanez worked at a towing company and had a young child with his 18-year-old girlfriend, who is five months' pregnant with their second child.

No Border Patrol agents were seriously hurt.

Calderon wrote on Twitter that he discussed the killing with U.S. Secretary of State Hillary Clinton at a meeting of regional leaders in Guatemala City.

"I demanded punishment for the guilty," he wrote.

Mexico's Foreign Relations Department urged U.S. authorities to swiftly investigate and questioned the "use of firearms to repel an attack with stones."

The union that represents Border Patrol agents defended the killing. Shawn Moran, a spokesman for the National Border Patrol Council, said the agent likely saved his colleague's life or spared him serious injury. The triggerman has been an agent for three years.

"The guy's a hero," said Moran. "He's a relatively junior agent, but he showed great poise in dealing with a really bad situation."

San Diego police are leading the investigation. They did not release names of the victim or the agents.

Three men climbed over the fence or went through an opening and confronted two agents, Herbert said. Two men fled back to Mexico, while the third man wrestled with one of the agents.

One of the men who fled climbed atop the fence and hurled objects at the agent who was wrestling, leading the other agent to fire his pistol, Herbert said. Authorities arrested the 44-year-old man who was wrestling; his name was not released.

Border Patrol agents in San Diego have long been pelted with rocks and other objects by people on Mexican soil, fueling occasional tensions between U.S. and Mexican authorities about how the Border Patrol should respond.

The American Civil Liberties Union of San Diego and Imperial Counties questioned the latest killing.

"We simply cannot allow our law enforcement agents to use lethal force when confronted with rock throwers," said Kevin Keenan, the group's executive director.