Additional District and Sessions Judge Himashu Bhatnagar also imposed a fine of Rs 2,12,000 on each of the seven accused -- Muzammil, Mujassim, Furkan, Nadeem, Janangir, Afzal and Ikbal -- for killing Gaurav and Sachin on August 27, 2013 and rioting.
The court said that 80 per cent of the fine will go to the family of the two men who were killed.
This is the first case out of total 57 in which the seven men were found guilty, district prosecution counsel Rajiv Sharma said.
The court had convicted the accused on Wednesday.
According to the First Information Report, the two youths of Kawal village under Jansath police station area were battered to death by three of the five men.
The two other accused, Afzal and Iqbal, however, were later summoned by the court under provisions of section 319 of the Criminal Procedure Code when the evidence of their complicity in the killings emerged during the trial.
The court convicted the seven after examining 10 prosecution witnesses and six in their defence.
As per official figures, given by prosecution counsel Sharma, over 6,000 cases were lodged following the 2013 riots and 1,480 accused were arrested for their alleged roles in the riots, in which over 60 people were killed.
A special investigation team, which probed the cases, have filed charge sheets in 175 cases.
Fifty-six of them involving 430 accused resulted in acquittal.
The state government has withdrawn some cases.
'1984 was the beginning, followed by 1992 and 2002'
With 195 incidents, UP still the hotbed for communal violence
India needs to quell the communal demon
Why the communal turn to politics should be avoided at all cost
'Wish we had got justice before': Victims of anti-Sikh riots