* Deby killed with troops on frontline
* Important Western ally in fight against jihadists
* Son named interim president
* Ruled for more than 30 years and just won another disputed election (adds analysts)
By Mahamat Ramadane
N'DJAMENA, April 20 (Reuters) - Chad's President Idriss Deby, who ruled his country for more than 30 years and was an important Western ally in the fight against Islamist militants in Africa, has been killed on the frontline against rebels in the north.
Deby's son, Mahamat Kaka, was named interim president by a transitional council of military officers, spokesman Azem Bermendao Agouna said in a broadcast on state television.
Deby, 68, came to power in a rebellion in 1990 and was one of Africa's longest-ruling leaders, surviving numerous coup attempts and rebellions.
His death was announced the day after he was declared the winner of a presidential election that would have given him a sixth term in office. Most of the opposition, which had long complained of his repressive rule, boycotted the vote.
Deby - who often joined soldiers on the battlefront in his military fatigues - visited troops on the frontline on Monday after rebels based across the northern frontier in Libya advanced hundreds of km (miles) south toward the capital N'Djamena.
"Marshal Idriss Deby Itno, as he did each time that the institutions of the republic were gravely threatened, took control of operations during the heroic combat led against the terrorists from Libya. He was wounded during the fighting and died once repatriated to N'Djamena," Bermendao said.
The government and National Assembly have been dissolved and a nationwide curfew imposed from 6 p.m. to 5 a.m.
"The National Council of Transition reassures the Chadian people that all measures have been taken to guarantee peace, security and the republican order," Bermendao said.
Deby had pushed through a new constitution in 2018 that would have allowed him to stay in power until 2033 - even as it re-instated term limits.
He took the title of Marshal last year and said before last week's election: "I know in advance that I will win, as I have done for the last 30 years."
He was dealing with mounting public discontent over his management of Chad's oil wealth and crackdowns on opponents. But in the election results announced on Monday, Deby claimed 79% of the vote.
Western countries have counted on Deby as an ally in the fight against Islamist militant groups, including Boko Haram in the Lake Chad Basin and groups linked to al Qaeda and Islamic State in the Sahel.
Former colonial power France had based its Sahel counter-terrorism operations in N'Djamena. Chad had announced in February the deployment of 1,200 troops to complement 5,100 French soldiers in the area.
Déby's death could mean tremendous uncertainty for Chad as the military is internally divided and because of the widespread domestic opposition, said Nathaniel Powell, author of a history of French military involvement in Chad.
"The swift announcement of the establishment of a military council and naming his son Mahamat as head of state however indicates regime continuity," Powell told Reuters.
"This probably aims to counter any coup-making efforts from within the security establishment and to reassure Chad's international partners - especially France but also the United States - that they can still count on the country for its continued contributions to international counter-terrorist efforts in the Sahel."
The latest rebel actions had already caused alarm in Washington and other Western capitals.
The rebel group Front for Change and Concord in Chad (FACT), which is based across the northern frontier with Libya, attacked a border post on election day and then advanced hundreds of kilometres (miles) south.
But the Chadian military appeared to have slowed its advance about 300 km (185 miles) from N'Djamena.
The rebels acknowledged on Monday that they suffered losses on Saturday but said they were back on the move on Sunday and Monday.
LOVED THE FRONTLINE
Déby had joined the army in the 1970s when Chad was going through a long-running civil war. He received military training in France and returned to Chad in 1978, throwing his support behind President Hissène Habré and eventually becoming commander in chief of the armed forces.
He seized power in 1990, leading a rebel army swathed in desert headgear in a three-week offensive launched from neighbouring Sudan to topple Habre, a man accused of instigating tens of thousands of political murders.
A senior regional diplomat told Reuters: "We understand from our sources that he was indeed on or near the frontline. He loved going on the frontline."
The speaker of parliament should have taken power on his death, the diplomat said.
"But it is not. That in itself is a coup," he said. "He has been grooming the son for some time. They will continue to face the rebellion. Deby had his hand in many things in the Sahel. His death disrupt things."
(Reporting by Madjiasra Nako and Aaron Ross, Editing by Edward McAllister and Angus MacSwan)
Our Standards: The Thomson Reuters Trust Principles.