While the morning after clean up was underway, Lam visited the mosque in Kowloon district, her head covered by a shawl, to express her sorrow to Islamic leaders over the incident.
The Hong Kong leader was due to depart for Japan to attend Emperor Naruhito's enthronement ceremony, and a government statement released later said Lam thanked Islamic leaders for repeatedly calling for calm during the political turmoil that has gripped the city in past five months.
During running battles in Kowloon on Sunday, police used tear gas and water cannon trucks to disperse petrol bomb-throwing protesters, spraying jets of blue dye into the crowds.
In one instance, a cannon drenched the front gate and footpath in front of the Kowloon mosque, Hong Kong's most important Islamic place of worship where a few people had gathered including journalists.
Blue stains from the dyed water remained on the road in front as worshippers gathered for prayers on Monday.
Protesters had said they would not target the mosque in Sunday's march after a leading pro-democracy leader was brutally attacked by masked men last week that the police said were "non-Chinese."
Some non-Chinese residents including those from South Asia have been recruited in the past by the city's organized criminal gangs, or triads, to attack individuals.
"South Asians have not been involved in any protesting — anti-Hong Kong or pro-Hong Kong. We’re just living peacefully,” said Waqar Haider, an interpreter who works with ethnic minorities.
In the statement issued by the government, Lam said Hong Kong's Muslim community called the city home and had always co-existed peacefully with other communities.
Chief Imam Muhammad Arshad said Lam's apology was "accepted" and that the Islamic community hoped to continue living in Hong Kong in peace.
Police said in a statement the mosque had been accidentally sprayed and that they "respect religious freedom and will strive to protect all places of worship."
"It's just a mistake. They apologized. They saw some protesters standing outside the gates. The protesters also apologized," said Mohammed Assan, 32, who was praying at the mosque at the time.
"The police do their work and the protesters have a right to protest. Everybody needs freedom. They demand to live with freedom."
After two weeks of relative calm, Sunday's large turnout of tens of thousands of protesters reflected strong support for the anti-government movement despite police branding the march illegal.
Families and the elderly took to the streets in what began as a peaceful march, many wearing masks or carrying umbrellas to shield their faces in defiance of an anti-mask law that authorities invoked this month to try to quell the unrest.
A more radical faction of mainly young protesters later clashed with riot police.
Across the Kowloon peninsula protesters torched stores and metro stations. Hundreds of shops were trashed, with mainland China banks and shops with links to the mainland targeted.
Many people in Hong Kong are angry at what they see as mainland China's attempts to limit the freedoms the semi-autonomous city is supposed to enjoy under the "one country, two systems" principle enshrined in its handover from Britain in 1997.
The protests pose the biggest popular challenge to Chinese President Xi Jinping since he took power. Beijing has denied eroding Hong Kong's freedoms and Xi has vowed to crush any attempt to split China.
Protesters are demanding universal suffrage, an independent inquiry into alleged police brutality, amnesty for those charged over previous demonstrations, and an end to the government's labeling of the protesters as rioters.
Sunday's unrest followed an annual policy speech last week in which Beijing-backed Lam sought to ease tensions with measures to resolve a chronic housing shortage.
She also has promised to withdraw a China extradition bill that ignited the unrest and engage in a dialog with the public, but has so far resisted other protester demands.
Since the protests escalated in June, over 2,600 people have been arrested, many under 18 years of age, while two people have been shot and many more injured.
As the economy faces its first recession in a decade, Hong Kong Financial Secretary Paul Chan on Sunday offered more support for small and medium-sized enterprises which have borne the brunt of the chaos.
Businesses will probably have to foot the bill for the vandalism, as few had insurance for riot damage, industry insiders said.