A witness said the shooters also wore police uniforms, and the federal Public Safety Department said it was investigating whether the attackers were active-duty police, former officers or impostors. Criminals in Mexico sometimes use false police uniforms.
The slain agents had gone to the airport "to detain suspects linked to drug trafficking at Terminal 2," the Department said in a statement. "Upon seeing themselves surrounded by federal police, they (the suspects) opened fire on the officers."
Two officers died at the scene and another died later of his wounds at a local hospital.
No suspects had been arrested following the shooting, which took place shortly before 9 a.m. (10 a.m. EDT; 1400 GMT). The federal Attorney General's office said that its organized crime unit had opened an investigation into the case.
The shootings occurred around the food court, near the area where vehicles drop off passengers but well outside the internal security checkpoints where workers and passengers are screened.
Three shots rang out at first, said witness Israel Lopez, a 23-year-old Mexico City student who had gone to the airport to see off a friend. Lopez didn't see who those shots were directed at, but then the gunfire came closer.
"We were in the food court, and some policemen came in and started shooting at another policeman who was on the floor," Lopez said.
"We dove to the floor and covered ourselves with chairs," Lopez said.
Lopez said the shooters wore blue uniforms like those worn by the federal police who provide security at the airport. He said the shooters then ran to the car park area "as if they were pursuing somebody," and he lost sight of them.
The airport said in a press statement that the terminal and flights were operating normally following what it described as "a dispute in an open-access area." But the food court remained blocked to public access for hours after the shooting.
Guadalupe Perez, 27, went to the airport to interview for a job when she saw the body of one of the officers on the floor. "It scared me a lot to see something like that, a body," she said.
Robert Gray, an evangelical missionary from Hart, Michigan, arrived at the airport after the shooting with his family to catch a flight.
"It's surprising to see it happening at the airport. It's one of the safest places in the city," Gray said.
But officials have long said that Mexico City's airport is used by traffickers to move drugs, money and illegal migrants. Federal police said they seized 198 pounds (90 kilograms) of cocaine at the airport in 2011 and 440 pounds (200 kilograms) so far in 2012. But violence related to drug trafficking has seldom, if ever, occurred in passenger areas at the airport itself.
In 2007, gunmen fatally shot high-ranking intelligence official Jose Nemesio Lugo, who investigated drug and migrant smuggling, as he drove to work. Lugo once served as the director of airports, seaports and border crossings for the federal Public Safety Department.
Later that year, the severed heads of three employees of a customs brokerage firm were found near the terminal and in the nearby state of Mexico. The decapitations were apparently a retaliation for the seizure of a half-ton of Colombian cocaine at the airport, officials said at the time.
In 2008, federal police chief Edgar Millan was gunned down inside his Mexico City home, and one of the suspects in that killing had worked as an anti-drug officer at the Mexico City airport.
The suspect had a notebook with detailed information on drug trafficking at the airport, and officials said federal investigations into those operations may have been a key motive for Millan's killing.