|The agents were attacked while they were driving through the state of San Luis Potosi [Reuters]
A US immigration and customs enforcement agent has been killed and another wounded while driving through northern Mexico.
Janet Napolitano, the US homeland security secretary, said one agent was critically wounded in Tuesday's attack and died from his injuries.
The second agent was shot in the arm and leg and remains in stable condition.
"I'm deeply saddened by the news that earlier today, two US Immigration and Customs Enforcement (ICE) special agents assigned to the ICE attache office in Mexico City were shot in the line of duty while driving between Mexico City and Monterrey by unknown assailants," she said.
US and Mexican officials said they were working closely together to investigate the shooting and find those responsible.
"Let me be clear: any act of violence against our ICE personnel, or any DHS personnel, is an attack against all those who serve our nation and put their lives at risk for our safety," Napolitano said.
"We remain committed in our broader support for Mexico's efforts to combat violence within its
The mid-afternoon shooting occurred when the two agents were driving in the northern state of San Luis Potosi. They were stopped at what appeared to be a military checkpoint, one Mexican official said on condition of anonymity.
After they stopped, someone opened fire on them, the official said.
San Luis Potosi is roughly half way between Mexico City and Monterrey, the country's business capital where drug-related violence has soared in recent months.
Television footage showed a blue sports utility vehicle with several large bullet holes lying in the median of the highway, which was guarded by heavily armed Mexican federal police.
Arturo Sarukhan, the Mexican ambassador to the US, spoke with John Morton, the ICE chief, to express Mexico's condolences.
"This is a difficult time for ICE and especially for the families and loved ones of our agents. Our hearts and prayers go out to them. This tragedy is a stark reminder of the risks confronted and the sacrifices made by our men and women every day," Morton said in a statement.
Though Mexico is seeing record rates of violence from warring drug cartels and a crackdown on organised crime, it is rare for US officials to be attacked.
The US government, however, has become increasingly concerned about the safety of its employees in Mexico amid the escalating violence.
In March, a US employee of a consulate, her husband and a Mexican tied to the American consulate were killed when drug gang members fired on their cars as they left a children's party in Ciudad Juarez, the city across from El Paso, Texas.
The US state department has taken several measures over the past year to protect consulate employees and their families.
In July, it temporarily closed the consulate in Ciudad Juarez after receiving unspecified threats.
In a famous case, in 1985 Enrique "Kiki'' Camarena Salazar, a US drug enforcement administration agent, was tortured and killed in Mexico.
Rafael Caro Quintero, a Mexican trafficker, is serving a 40-year prison term for Camarena's slaying.
ICE, the investigative arm of the US department of homeland security, created in 2003, is the second largest investigative agency in the federal government.
It enforces immigration laws and is primarily responsible for arresting, detaining and deporting people who are in the US illegally.
It also investigates drug cases in the US and Mexico and other types of trafficking.