Ramon Pequeno, head of the Mexican anti-narcotics police, said the Gulf and La Familia cartels were now fighting a group called the Zetas.
They are fighting over a lucrative drug transit point on the US border.
The Zetas began as hitmen for the Gulf cartel in the 1990s but recently pushed for their own share of the drugs trade.
Believed to have emerged from among Mexican army deserters, they are notorious for their readiness to behead victims. Their criminal activities are believed to include drug-trafficking, extortion, migrant-smuggling and kidnapping.
Nearly 18,000 people have been killed in drugs-related violence in Mexico since 2006.
Some 40,000 soldiers have been sent to border regions to fight the cartels.
'War on everybody'
The shift in allegiances is apparently fuelling drug-related violence along Mexico's border with Texas.
Intelligence reports indicated the Gulf cartel had recruited La Familia to crush the Zetas in the border state of Tamaulipas, said Mr Pequeno.
An official with the US Drug Enforcement Administration (DEA) said a third cartel, the Sinaloa, had also joined the alliance against the Zetas.
"It's an issue of a common enemy," Will Glaspy, head of the DEA office in the border town of McAllen, told the Associated Press news agency.
Banners began appearing in Tamaulipas earlier this year announcing the campaign by "the cartels of Mexico united against the Zetas".
One banner even urged President Felipe Calderon to withdraw the army and let the new alliance exterminate the Zetas, AP notes.
Another which was hung from bridges read: "The Gulf Cartel separates itself from the Z [ie the Zetas] in our ranks. We don't want kidnappers, terrorists, bank robbers, rapists, child killers and traitors."
Videos and e-mails were sent around warning families to stay at home, saying the conflict would get worse.
Mr Pequeno said that La Familia, whose stronghold is in the Pacific coast state of Michoacan, had sent a large number of gunmen across the country to Tamaulipas to help the Gulf cartel wipe out Los Zetas.
"The Zetas have been trying to wage war on everybody for a while," Mr Glaspy added.
"It's been well documented that the Gulf cartel has formed alliances with the Sinaloa cartel and [La Familia] to wage war against the Zetas."