At least 21 people have been killed in a gunfight between two of Mexico's most powerful drug cartels near the border with the US, officials have said.

The incident occurred off a remote dirt track near the city of Nogales, in the northern state of Sonora, they said.

Nine people have been arrested, six of whom were wounded in the confrontation.

Correspondents say gangs are involved in smuggling drugs and people to the US, and have been battling for control of the area - a key trafficking route.

However, they rarely stage such large-scale shootouts, they add.

There was no indication about what specifically triggered Thursday's gunfight between the Sinaloa cartel, led by Joaquin "El Chapo" Guzman, and an offshoot, the Beltran Leyva cartel.

All of the victims were believed to be members of the gangs.

MEXICAN ELECTIONS 4 JULY 14 of 31 states holding elections

12 of them choosing new governor

Elections also for state deputies, mayors and councils Gangs cast shadow over elections

The BBC's Julian Miglierini in Mexico City says the fact that the violence happened only 20km (12 miles) from Arizona will do little to allay US fears that Mexico's unrest is getting increasingly close.

On Wednesday night in the northern border city of Ciudad Juarez, gunmen killed Sandra Salas Garcia, an assistant attorney-general of Chihuahua state, and one of her bodyguards.

Meanwhile, a severed head was reportedly left on Thursday outside the home of the leading candidate for the mayor of Ciudad Juarez, Hector Murgia. Fourteen states will hold elections on Sunday.

For months, candidates have complained of intimidation by the gangs and have been forced to limit their campaigning in high-risk areas.

Rodolfo Torre Cantu, who was running for governor in the north-eastern state of Tamaulipas, was shot dead along with four of his supporters near Ciudad Victoria on Monday.

Surge in violence

Earlier this month, President Felipe Calderon deployed thousands more troops to the worst-affected areas along the US border as part of his "war on drugs".

In a televised address, he appealed to the nation to help combat the escalation of violence which has shaken the country.

"This is a battle that is worth fighting because our future is at stake," he said. "It's a battle that, with all Mexicans united, we will win."

Last month, Mr Calderon asked a joint session of the US Congress for support, saying it was crucial that the flow of weapons from the US to Mexico was curbed.

Despite his appeals, drug-related violence has surged and this year is on track to be the deadliest in half a decade, with some 5,000 killings so far - more than the totals in 2007 and 2008.

Nearly 23,000 people are thought to have been killed since President Calderon launched his crackdown on the cartels in December 2006.