Werner was in the final year of his contract and would have left for free at the end of the season.
The 23-year-old’s impressive performances for Leipzig in the last three seasons have seen clubs including Bayern Munich eye a move for the German.
Bayern Munich were reportedly waiting to pounce once Werner’s contract came to an end but will now have to fork out €30m if they are to get him.
Werner has already scored two goals in two games in this season’s Bundesliga with RB Leipzig sitting third on the table.
"I'm glad that I signed with RB Leipzig and thus extended my contract," he said.
"Of course, this process has been going on for a very long time, but I really wanted to be completely sure that I could take the next steps in the development of this club.
"And for the right decisions you just need a little longer. Now I can fully concentrate on playing as successful a season as possible with our team."
Managing director Oliver Mintzlaff added: "We are glad that the negotiations with Timo Werner have now come to a positive conclusion and he has decided to extend the contract with us.
"We have had many intensive discussions over a long period of time and have been very attentive to and valued by Timo.
"We are glad that we now have clarity and are pleased that Timo remains an important part of our team."
Werner has won 25 caps for the German national team scoring 10 goals.