Residents of the capital, on Chad's western border with Cameroon, sheltered in their homes as rebels who had slipped in under cover of night battled with government troops in a northeastern neighbourhood early on Thursday.
The sounds of artillery and small arms fire echoed across the city for several hours before easing later. Some residents reported seeing armed rebels in pick-up trucks.
Idriss Deby, the president, said his forces had repulsed the rebels and were in complete control of the capital.
He accuses neighbouring Sudan of supporting and arming the rebels, who are fighting to end his nearly 16-year rule and disrupt a presidential election scheduled for May 3 in which he is standing for re-election.
"The situation at this moment in N'Djamena is totally under control," Deby told French radio RFI. He said he was speaking from the presidential palace in N'Djamena.
Speaking in Cairo, Ahmat Allami, Chadian foreign minister, accused Khartoum of supporting the rebellion in an act of "premeditated aggression" against Chad.
French officials said the rebels appeared to be isolated units and that the main advancing insurgent column was halted by government forces late on Wednesday at Linia, 30km outside N'Djamena.
A French warplane - part of a 1,200-strong French military contingent stationed in Chad - fired a warning shot over the rebel column on Wednesday, a French Defence Ministry spokesman said in Paris.
He added French aircraft had also flown reconnaissance flights over the rebel positions on Thursday.
The raid on N'Djamena was claimed by the rebel United Front for Democratic Change (FUC), which said it also attacked the eastern town of Adre near the Sudan border.
"Our forces have entered Adre," FUC leader Abdoulaye Abdel Karim told Reuters by satellite phone. He said he was in Chad.
But General Mahamat Ali Abdallah Nassour, Chad's territorial administration minister, said the government was in control of Adre, which he said was attacked by "Sudanese forces".
"We've wiped out these attackers," said Nassour.
Government officials paraded some 50 rebel prisoners they said were captured along with vehicles and weapons. The prisoners were young and dressed in camouflage uniforms.
After the fighting had subsided in N'Djamena, a Reuters reporter who crossed the city said it was calm, though few people ventured out. He saw military patrols in the streets.
The president vowed the May 3 poll would go ahead and said he would be out campaigning in public later on Thursday.
The vote will see Deby, who won power in a 1990 military revolt, facing four candidates with links to his government. He is expected to win.
The opposition is boycotting the polls.
Meanwhile, Sudanese officials said on Thursday large numbers of Chadian civilians fleeing the escalating fighting between government troops and rebels have been crossing into Sudan's western region of Darfur.
"A large number of Chadians, mostly women, children and elderly, have fled the fighting at home and crossed the border into West Darfur state," the state's parliamentary speaker, Sultan Saad Bahr el-Dinn, told AFP.