A mob angry about recent child abductions cornered plainclothes federal agents taking photos of students at a school and burned the officers alive, mistaking the agents for kidnappers.
Officials said two agents were killed and one was hospitalized.
Federal police said the three agents went to the school on Mexico City's southeastern outskirts in an unmarked car as part of an operation against drug dealing.
The killings, filmed and broadcast on local television stations, were carried out by a crowd of people who cheered, chanted and shouted obscenities as they kicked and beat the agents. The mob then dowsed two officers with gas and set them ablaze.
Police didn't make any immediate arrests; officials said they were investigating.
In the video, the agents spoke into the cameras before the burning, saying they were federal anti-terrorism agents who had been sent there on official business.
The agents were held by the mob for several hours before they were killed. Police said heavy traffic and residents kept officers from responding in time.
The third agent, badly beaten, was rescued by police.