The striker, who had been on loan from Bayern Munich, scored 11 goals in the Bundesliga last season and was delighted to secure a long-term deal with the side.
"This is the news I've been waiting for, now I am very happy that everything turned out the way I liked it.," he told the club's website.
"I am highly motivated for the new season. I want to help so we again make a big step forward."
Petersen first caught the eye after scoring 35 goals in 56 league games for Energie Cottbus before Bayern came calling.
The German found opportunities limited with the Bavarians, making just nine Bundesliga appearances in 2011.
This led to a loan spell to Werder, who have been impressed with his contribution since his arrival.
"We are very pleased that Nils will spend the coming years with Werder, hunting for goals," said club chief executive Thomas Gauge.
"He has shown in the past season he fits perfectly here. We are sure he still has huge potential and will develop, and will continue to be a strong pillar of the team."