The 21-year-old came through the youth system at Roma before joining Sassuolo in the summer of 2015, and the midfielder has scored 11 times in 53 appearances over the last two seasons.
Earlier this week, Roma general manager Mauro Baldissoni revealed that Pellegrini was on the verge of returning to the Yellow and Reds, and the deal, for the buy-back price of £8.7m, has now been confirmed.
"It is an incredible feeling to come back. This was my objective from the moment I went to Sassuolo. It is the culmination of a great two-year journey with them," Pellegrini told Roma's official website.
"I want to thank Roma, including Monchi and the rest of the directors. They have always been in close contact with me. They made me realise how much they wanted me back."
Pellegrini was a part of the Italy Under-21s squad that reached the semi-finals of this summer's Under-21 European Championships in Poland.