Lewis had been fastest during practice and topped the second part of qualifying, but Valtteri stuck his car on provisional pole with his first run in Q3.
Valtteri clocked a 1:36.231 to edge Lewis early in the final shootout, and when the four-time World Champion failed to improve on his second run pole went to the Finn for the fourth time this year.
"It's only the fourth pole of my whole career and I had to beat some pretty good qualifiers, so it's a great feeling to start from P1 tomorrow," said Valtteri.
"It was a really good qualifying, clean and smooth. With the changes we made, the car was behaving much better in qualifying than it did in free practice. Run after run, I could always find some time here and there, I really worked on the details.
"But the weekend is not over yet; we want to finish strong tomorrow as well. We were nearly there in Sao Paulo and now I get a second opportunity.
"It would mean a lot to end the season on a high. However, no matter how tomorrow goes, it will be nice to head into the winter break knowing that I had the speed to be on pole two races in a row.
"That's a good feeling and a good basis to start working for 2018."