35-year-old Rossi is considered one of the sport's greatest competitors having won seven top-tier world titles and 80 races. His form dipped during a two-year spell at Ducati, but the Italian has been impressive again this season, netting five podiums.
He will now race for two more campaigns after 2014, meaning he will be at least 37 before calling time on his career.
“I am very happy to announce that I have signed a new contract with Yamaha to continue together in MotoGP for the next two years," said Rossi.
"I am very proud of this announcement. It’s very important to me because I really enjoy working with my crew and all the guys from the team, both the Japanese and European members that have been with me almost my entire career.
"It’s great because this was my target; I wanted to continue, I am feeling good and I’m motivated to keep giving my best. I am very happy that I can keep riding my YZR‐M1, that has been my love for so many years and will still be my love this year and the following two seasons.
"A big ‘Thank You’ to everybody, I will try to keep giving the maximum to arrive in front and make good races. Enjoy!”
Rossi currently sits second in the MotoGP standings, 72 points behind runaway leader Marc Marquez.