He allegedly invited the other men, aged between 23 and 66, to rape the child after giving her spiked soft drinks to sedate her. According to local reports, the accused men took the girl to the building's basement, terrace, gym and public rest rooms to carry out the attacks over the past seven months. They reportedly filmed each other raping the girl while brandishing knives before blackmailing her and threatening to release the videos if she told police.
"This is the initial stage of investigation and we have to go in-depth to ascertain the details," a local police official told AFP.
India has a grim record of sexual violence but the incident has still rocked the country to its core. Indian television channels ran lengthy news segments with banner headlines which read, simply, "Chennai Horror".
"An entire community got together to rape a child. I cannot even fathom the depravity and horror of this act," Rohini Singh, an Indian journalist, wrote on Twitter.
The case has sparked widespread revulsion and some of the accused were attacked by a group of lawyers during the court appearance, the Hindustan Times reported.
Video shared on social media showed a man being dragged from a staircase and beaten up as police struggled to restore order.
Speaking to journalists at the Chennai High Court, advocate association president Mohana Krishnan said no lawyer was willing to appear on behalf of the accused, according to the BBC. Since the news of the attacks broke on Monday, local women have volunteered to stand guard at the complex's entrances, as residents dismiss remaining staff.
The incident came to light after the girl told her family who then lodged a police complaint. She is now receiving medical attention.
"We arrested all the 18 accused for the heinous crime," a local police officer said on condition of anonymity. They have been charged under the Protection of Children from Sexual Offences (POCSO) Act.
The Indian Government recently approved stringent punishments for sexual violence against children, including the death penalty for those convicted of raping girls younger than 12.
The decision came amid spiralling outrage over the January rape and killing of an eight-year-old girl in Jammu — who died after being kidnapped, drugged and gang-raped while locked in a Hindu temple — and several other cases of sexual assault involving minors in recent months.
In May, a teenager in Central India was set on fire after her parents told a village council that men in the area had raped their daughter, the NY Times reported. In June, a seven-year-old was raped in the state of Madhya Pradesh, also in Central India. Afterwards, the two men slit her throat and left her to die.
A poll released in June by the Thomson Reuters Foundation named India the most dangerous country in the world for women, ahead of war-torn countries including Afghanistan and Syria.
In India, a rape occurs at least every 20 minutes, according to data from the National Crime Records Bureau. Some 19,000 attacks on minors were reported in 2016, but vast numbers are never brought to police attention.