Some residents displayed the Union Jack flag in their windows to avoid being targeted by what the local police chief described as “racist thuggery, pure and simple”.
Several houses had signs declaring “Filipino lives here” - apparently in the hope of redirecting attackers to other targets.
Riot squads were brought in from around Britain as reinforcements, and video showed police using water cannons to blast the advancing mobs.
Five people were arrested, and police said they were reviewing footage to identify additional participants in the melee.
The unrest, which officials warned could continue for a third night or longer, is the latest example of riots in British communities where tensions over migration have run high.
Four days of riots erupted in a suburb of Liverpool, England, last year after a person arrested for killing three girls at a dance event was falsely identified online as a Muslim asylum seeker.
Last month, after a driver ploughed into a crowd celebrating a football championship, Liverpool police broke precedent by quickly identifying the suspect as a white British citizen to head off spiralling disinformation and racial conflict.
The unrest in Ballymena began after the arrest on Monday NZT of two 14-year-old boys on suspicion of sexually assaulting a girl, officials said.
Authorities did not identify the suspects, but when the pair appeared in juvenile court by video link on Tuesday, the charges of attempted oral rape were read to them by a Romanian interpreter, sparking widespread speculation that they were from Eastern Europe.
Court officials have released no further information about the suspects, and their nationality and residency status in the United Kingdom remained unclear. They were denied bail and are scheduled to appear again in court on July 2, the BBC reported.
Anger at the arrests spread quickly.
A vigil, originally organised to support the victim, quickly turned violent on Tuesday when some participants broke away and began smashing windows in a part of the city where many immigrant families live and close to where the alleged assault occurred.
Protesters set up barricades and gathered blocks and other projectiles to hurl at police.
Officials said they did not believe the violence was planned by organised groups.
They detected no involvement by the paramilitary groups that still exist in Northern Ireland but in forms far diminished from the days when the region was beset by sectarian strife.
But rioters were connecting with others through the internet, the authorities said.
There was “widespread live-streaming on social media of the violence, directing people where to go, how to get around the police barricades”, Sian Mulholland, Ballymena’s Legislative Assembly representative, told the BBC.
Mulholland described helping to evacuate a pregnant woman from one burning house.
“We were able to direct the police to remove that family and get them out of the area to safety, to the police station,” she said.
The violence was largely quelled yesterday, police said.
The family of the alleged assault victim condemned the violence, and the authorities called for the public’s assistance in helping to trace the perpetrators. The police also said they were readying for a third night of trouble.
Prime Minister Keir Starmer’s office said it was monitoring the situation, calling it “very disturbing”.
Officials said additional reinforcements were ready to be deployed from England and Wales if needed.