The incident took place under Masuri town police station area and family members of the deceased have identified the assailants, the police said.
Senior Superintendent of Police or SSP Vaibhav Krishna said Mahendra, a Dalit, was returning to his home this evening after parking the vehicle on a private school premises.
When he was just a few yards away from his home, the five bike-borne assailants opened fire at him, leaving him dead on the spot, and fled, Mr Krishna said.
Anil, the brother of Mahendra, told police that on February 12, 2009 their father Sahib Ram, a labourer, was shot dead during the wedding procession of his brother.
The "higher caste" people of the village were opposing the procession, the official said, adding that the murder case of the father is still under trial in a district court.
In a bid to prevent Mahendra, who was the main witness in the murder case, from testifying against them, they shot him dead, Mr Krishna said.
A few days ago they had allegedly threatened Mahendra not to give evidence in his father's murder case.
The body has been sent for postmortem and an FIR is yet to be filed, Mr Krishna said.