The Col de la Couillole, which stands 1,678 metres tall to the north of Nice, is the highest finish in the 75-year history of the race.
The BMC rider, who dropped out of contention in the second stage, attacked with 3.2km left and crossed the line 21 seconds ahead of Alberto Contador (Trek-Segafredo).
"It hurt so much but it was such a sweet victory after the disaster we had early in the week,” Porte said. “But I must take my hat off to the team, they were absolutely incredible all week and they never lost faith in me. So I say a big thank you to them. I wasn't always easy to deal with this week."
Dan Martin (Quick Step Floors) was third after jumping ahead of Sergio Henao on the line, who the took the overall leader's yellow jersey as Team Sky closed in on a fifth victory in six years in the Race to the Sun.
Julian Alaphilippe (Quick-Step Floors) started the day with the yellow jersey but cracked in the final climb, a 15.7km ascent at an average gradient of 7.1 per cent, and dropped to fifth overall.
Henao, who was dropped by Contador with 1.2 km left, leads Martin by 30 seconds and the twice Tour de France champion by 31 seconds.
“The day went well for me. We will see what happens in the final stage. I remember last year Geraint Thomas only just won it,” Henao said.
“I’m expecting it to be difficult. Dan Martin is dangerous, you only need to look at the way he came back today. His team also has Alaphilippe and Contador is also ready for the fight.”
Contador and Martin are expected to be on the attack in Sunday's final stage, a punchy 115.5km trek with two category-one climbs.
"I did know this climb. Two weeks ago we did reconnaissance of it. It was a beautiful climb. We were lucky with the weather that we could get this high. It's the highest finish of Paris-Nice ever which is incredible. I'll take great memories from this."
"It was hard to line up on Tuesday after stage 2, but it makes you a little bit hungrier. I had a couple of little goes at it on the way up. I didn't so much as attack, but more rolled off the front a little bit there. The others didn't have to chase me for GC but the last 3km were absolute hell. To finish it off is a great way to finish the week."
"The boys rode on the front basically from kilometer 0 to put me in the good position. I must tip by hat to those guys. It's not over. We still have another hard stage tomorrow. It's nice for me to take a bit of a backseat and sit back and watch the fireworks. I think it's going to be a spectacle tomorrow. It will be a really exciting race."