Sections of Muslim groups in Sambhal protested against this, alleging that they were not given any prior notice about it. They have also questioned the urgency with which the court ordered the exercise.
A second survey of the mosque was held on Sunday morning, which turned violent after a large group of protesters gathered near the mosque and began shouting slogans at the survey team, police say.
Top police official Aunjaneya Kumar Singh told the Hindu that protesters allegedly pelted stones at the police, leaving them with no option but to use force to escort the survey team to safety.
He added that tear gas shells and plastic bullets were fired to disperse the crowds.
Mr Singh identified the three victims as Naeem, Bilal and Nauman and said they died of bullet injuries sustained during the clashes.
Opposition leaders have criticised the state government and accused it of orchestrating the violence for political gain - a charge it denies.
"No one is allowed to take law into their own hands," Uttar Pradesh's Deputy Chief Minister Brajesh Pathak told the Indian Express newspaper, adding that authorities were investigating the incident.
Mahmood Madani, president of Jamiat Ulama-i-Hind - a leading organisation of Islamic scholars - condemned disputes around mosques in the country, saying they violate Indian laws.