Rached Ghannouchi was arrested on charges of incitement against state authorities.
The 81-year-old is the head of the Islamist Ennahdha movement and had previously presided over the Tunisian parliament before President Kais Saied — of whom Ghannouchi is a major critic — shut it down in what opposition groups have called a "coup."
The judge carried out an eight-hour investigation before ruling on Ghannouchi's detention. He is to be held until his trial, although no date has been set for the next hearing.
Ennahdha condemned the judge's ruling, calling it an "unjust decision" and saying that it was targeting a "national symbol" who had spent decades fighting dictatorship in Tunisia.
"This political decision aims to cover up the abysmal failure of the coup authority in improving citizens' social, economic and living conditions and an inability to address a stifling financial crisis that is driving the country to bankruptcy," the movement said.
Ghannouchi was arrested after remarks he had made warning that there would be a civil war if political Islam, or any other political faction, were sidelined.
His lawyer said that detention had been pre-planned due to his expressions of opinion.
Suppression of opposition forces
Numerous other opposition political figures have been arrested in Tunisia in recent months.
Many had accused Saied of carrying out a coup after he closed parliament, began to rule by decree and rewrote the constitution.
The president has banned meetings at Ennahdha offices and shut down the headquarters of the main opposition coalition Salvation Front, of which Ennahdha is a partner.
Saied has defended his actions, saying they were necessary to prevent Tunisia from falling into chaos while calling his enemies criminals, terrorists and traitors.
Tunisia ousted its longtime dictator in a revolution in 2011, part of the wider Arab Spring.
ab/nm (Reuters, dpa)