Homeland Security Secretary Janet Napolitano said one agent was critically wounded in the 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 U.S. 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.
U.S. and Mexican officials said they were working closely together to investigate the shooting and find those responsible.
The motive for the attack wasn't immediately known.
"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 borders."
The two agents were driving in the northern state of San Luis Potosi when they were stopped at what appeared to be a military checkpoint, said one Mexican official, who could not be named because he was not authorized to speak publicly about the case.
After they stopped, someone opened fire on them, the official said.
San Luis Potosi police said gunmen attacked two people a blue Suburban on Highway 57 between Mexico City and Monterrey, near the town of Santa Maria Del Rio, at about 2:30 p.m. Police said one person was killed and another was flown to a Mexico City hospital, though they couldn't confirm the victims were the ICE agents.
Mexican Ambassador to the U.S. Arturo Sarukhan spoke with ICE chief John Morton to express Mexico's condolences, according to a spokesman.
"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 organized crime, it is rare for U.S. officials to be attacked. The U.S. government, however, has become increasingly concerned about the safety of its employees in Mexico amid the escalating violence.
In March, a U.S. 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 U.S. State Department has taken several measures over the past year to protect consulate employees and their families. It has at times authorized the departure of relatives of U.S. government employees in northern Mexican cities.
In July, it temporarily closed the consulate in Ciudad Juarez after receiving unspecified threats.
In a famous case, in 1985 U.S. Drug Enforcement Administration agent Enrique "Kiki" Camarena Salazar was tortured and killed in Mexico. Mexican trafficker Rafael Caro Quintero is serving a 40-year prison term for Camarena's slaying.
ICE, the investigative arm of the U.S. Department of Homeland Security and the second largest investigative agency in the federal government, enforced immigration laws and is primarily responsible for arresting, detaining and deporting people who are in the U.S. illegally. It also investigates drug cases in the U.S. and Mexico and other types of trafficking.
It was created in 2003 through a merger of the investigative and interior enforcement elements of the U.S. Customs Service and the Immigration and Naturalization Service and has more than 20,000 employees in offices in all 50 states and 47 foreign countries.