The 26-year-old, used regularly at right-back this term and also occasionally on the right side of midfield, put pen to paper at Camp Nou on Thursday evening.
Manchester City and Manchester United are among the sides to have shown a rumoured interest in the versatile ace, who has been a part of the Barca fold since 2006 and gone on to make more than 100 senior league appearances.
Roberto is pleased to have committed his future to the Catalan giants, though, and is now hoping to follow in the steps of some legendary players.
"Since renewal talks began I always wanted to be here. It's the club of my life and I've been a fan since I was small," he told the club's official website.
"It's true that other clubs were interested, but I wanted to be here and I'm happy to have renewed until 2022. If I can continue even longer, then so much the better.
"I hope it's not the last contract I sign. My desire is to retire here and hopefully I can follow in the footsteps of Andres Iniesta and Leo Messi."
Roberto has appeared 30 times for Barca this season in all competitions, with all but six of those being starts.