Lorenzo Pellegrini gave Roma the lead in the first half but Gervinho looked to have snatched a point with an equaliser inside the final five minutes until Diego Perotti grabbed a late winner.
However, the home side’s slim chances of Champions League qualification ended as Inter Milan, Atalanta and AC Milan recorded wins to finish above them.
De Rossi in hospital after testing positive for Covid-19
Roma’s decision not to offer De Rossi a new contract was met with furious protests from the fans, but a capacity crowd said an emotional farewell to their second-highest appearance holder as he pulled on the red and yellow shirt for 616th and final time.
Claudio Ranieri, taking charge of Roma for the last time as caretaker manager, knew that his side needed everything to go their way to climb into the top four but they had to settle for sixth instead, earning them a place in the Europa League second qualifying round next season.
Mourinho: Southgate can call me 'John'
Betis record second win under Pellegrini, Granada continue to soar