The deal will run through to the summer of 2021.
The 29-year-old joined the Italian side in January 2014 and has scored 27 goals in 161 games for the club.
After signing the deal, Nainggolan told the Roma club website that: "I have shown that I have always wanted to be here. I'm really happy to be staying here."
Roma president Jim Pallotta said that the club was "very happy that Radja has committed himself to the club long-term during the most important stage of his career."
"Last season he showed that he is one of the best midfielders in the world and it is no surprise that he has been linked with some top European sides. But there was never the possibility of him leaving, he loves Roma and we're delighted to have him here," he continued.
UFFICIALE @OfficialRadja rinnova fino al 2021 https://t.co/JvmXKuXIN2#Radja2021 #ASRoma #Nainggolan pic.twitter.com/0TCRusMnlM
— AS Roma (@OfficialASRoma) 27 July 2017