Ousted former Peruvian President Pedro Castillo will remain in pre-trial detention for 18 months, the country's Supreme Court ruled, as crowds of his supporters protested outside the courthouse and across the country, CNN reported.

Castillo, a former teacher and union leader from rural Peru, was impeached and removed from office last week after he tried to dissolve Congress and install an emergency government, a tactic lawmakers have called a coup attempt. He has since been accused of sedition and conspiracy, which he denies.

The long detention reflects the complexity of the case and the possible risk of flight, Supreme Court Justice Juan Carlos Chekley said after prosecutors warned that the former president could seek asylum outside the country and said 18 months would cover the length of their investigation.