Rossi, a seven-time world champion and legend of the sport, took part in the final race of his illustrious career on Sunday, having confirmed the 2021 season would be his last back in August.
The 42-year-old qualified in 10th and ultimately finished in the same position, achieving the top-10 finish he had identified as his goal heading into the weekend.
Rossi was mobbed at the end of the race, with his rivals, fans and crew all swarming around him before lifting him aloft of the track.
He was then treated to special tributes from other teams as he headed back down the pitlane for the last time, before something of a party began in the Yamaha paddock.
Bagnaia won the race after seeing off Jorge Martin, and the Italian – who came through Rossi's VR46 academy – dedicated the win to his hero.
"It was very exciting because with a helmet like this I could only win," the Ducati rider told Sky Sport Italia while holding a replica of Rossi's 2004 helmet.
"It is the only way to celebrate the greatest of all, it was beautiful. The hug with Vale was wonderful, I was able to pass on to him what he is for me, and all the gratitude for what he's done. Without him I would not be like this at the moment.
"I wanted to give Valentino a gift with my helmet and dedicate this race to him. I thank him for what he did for us at the academy.
"Before the weekend I wasn't sure I could do performances like this here. In the end, we were among the fastest and I'm happy to have won. It's the best way to end a season."