MEXICO CITY  Gunmen on a highway in northern Mexico killed an agent with United States Immigration and Customs Enforcement on Tuesday and wounded another, in an attack that signaled the escalating risk for American officials fighting Mexican crime gangs that move drugs and migrants into the United States.

The United States homeland security secretary, Janet Napolitano, said in a statement that the agents were assigned to the customs agency’s attaché office at the American Embassy in Mexico City, and that they had been shot in the line of duty while driving between the city and Monterrey.

The agent who was killed was identified as Jaime J. Zapata. He joined the agency in 2006 and served in Laredo, Tex., before a recent assignment to Mexico City. The name of the other agent was not released, but a statement from the immigration and customs agency said he was in stable condition.

It was the first time that an employee of the immigration and customs agency had been wounded or killed in the line of duty in Mexico, American officials said.