The incident took place in Mehndipur village when a motorbike hit some people. A verbal spat soon turned into a violent clash and shots were fired at the scene.
Three people - Danish, Jalish and Munna - were killed on the spot while over a dozen sustained injuries.
Rampur is state minister Azam Khan's home town. He is also the legislator from there.
Senior district and police officials rushed to the spot after which the situation was brought under control.
Police said there was some simmering hostility between the two sides but the village panchayat had intervened and apparently cleared up the matter.
The clashes come two days after violence in Saharanpur town of Uttar Pradesh Saturday after the high court verdict in a land dispute case led to some construction work on land claimed by a local gurdwara.
Members of the Sikh and Muslim communities pelted stones and fired at each other. Three people were killed and a dozen injured in this incident.