“It was difficult to look at,” he said.

Agent Martinez, 36, was killed, and a second agent who had apparently come to his aid was seriously injured. The F.B.I. was looking into the possibility that the men were attacked, but did not say Monday whether any arrests had been made.

Details were thin, but the episode in a remote stretch of Texas quickly made its way into the national conversation on immigration and border security. While Border Patrol fatalities are relatively rare, agents are not infrequently attacked on the job. And despite a dramatic drop in border crossings under the Trump administration, assaults against officers have risen, according to data maintained by the border agency: 720 in the recently-completed fiscal year, the highest number in at least five years.

Chris Cabrera, a spokesman for the National Border Patrol Council, the officers’ union, said that individual border agents often arrest dozens of people at a time without any help from colleagues. Most people surrender, but that is not always the case. A favorite tactic among border crossers is to hurl debris from the rugged terrain at officers, and Mr. Cabrera said that he had personally been on the receiving end of rocks thrown at him that were the size of grapefruits.

“If they hit you in the head, you’re going to go to sleep,” he said.

Over the weekend, the agents had been patrolling along a remote section of the border near Interstate 10 in Culberson County, Tex., where drug and human trafficking are common.

Mr. Cabrera said that according to other officers who were on duty, Agent Martinez went to check out a Border Patrol ground sensor that had been activated. The sensors, concealed devices that remotely alert agents when triggered, can be set off by wild animals, dying batteries or even the wind. Agent Martinez confirmed over his radio that it had been set off by humans, Mr. Cabrera said.