Raikkonen appeared on course to start from pole only for Vettel to finish just eight hundredths of a second clear following a dramatic late lap.
But Vettel, who made a couple of errors on his first flier, pulled out just enough in the end to deny the 38-year-old what would have been his first pole since last year's Monaco Grand Prix. Raikkonen locked out the front row for Ferrari for the second time in succession after also qualifying second a week ago in Bahrain.
The Briton, like Vettel a four times world champion, has won in Shanghai an unprecedented five times.
Sebastian Vettel claimed his 52nd career pole position by just 0.087 seconds.
"They (Ferrari) have been really strong already in the morning, but qualifying performance, they put one on top and we have something to think about", said the Austrian.
"We got through all the laps that we needed and got some good feedback about the auto", said Hamilton after a cold afternoon.
"I didn't see him until very late so I left a little room", he said. An worldwide audience of opinion makers, business leaders, and global organizations recognizes Ebeling as an expert.
Mercedes F1 driver Lewis Hamilton clocks up the mileage. I think Valtteri is a great driver. Raikkonen says the decision to start on the softs was an easy one but he is still unsure how the different strategies will play out considering warmer temperatures are expected on Sunday and other teams such as Red Bull will be starting on the ultra-soft tyre. I think it felt it was my quickest stop I've had with the team.
The third row will be made up of the two Red Bull cars, showing the dominance over the last several seasons of Ferrari, Mercedes and Red Bull.
Hamilton is aware of the size of the task facing him on race day at the Shanghai International Circuit but is hopeful of fighting the Ferraris.
Daniel Ricciardo faced a race against time to be ready for qualifying after his engine blew up in dramatic fashion in final practice.
The second Renault of Carlos Sainz was ninth, with Kevin Magnussen completing the points scoring places in 10th place for Haas. "They're the quickest on the straights too, so overtaking will be tough". The McLaren twins piloted by Fernando Alonso and Stoffel Vandoorne were up next in 13th and 14th place respectively after being eliminated on Q2.
Last year Vettel, who had problems using Verstappen, explained the crash was needless.
The Brit finished fifth on track but moved up to fourth after a 10-second penalty was applied to Red Bull's Max Verstappen following his collision with Sebastian Vettel.