Both Mercedes drivers lost time on their final runs on the soft tyres, with Hamilton having to abandon his lap after going off and nearly hitting the barriers in the runoff area at Turn 13.
Max Verstappen was the fastest Red Bull driver in seventh, but he also spun while attempting a second qualifying simulation in the 90-minute session.
After Romain Grosjean and Lando Norris had set the pace during the early running, Bottas and Hamilton then swept to the top of the times with a 1m36.065s and a 1m34.890s on their first FP2 laps on the hard and medium tyres respectively.
Daniel Ricciardo slotted in ahead of Bottas during his first run on the mediums before the Mercedes drivers switched to the softs with just over 20 minutes of the session completed.
Bottas used his red-walled rubber to retake P1 with a 1m33.883s, but Hamilton quickly demoted him back to second with his best time of the session – a 1m33.786s.
The two championship leaders then returned to the track for a second qualifying simulation run on the softs, where both showed rapid pace but made key mistakes.
Hamilton had just set the best times in the opening two sectors and was 0.7s up on his best time when he locked up at the big stop of the Turn 13 right-hander at the end of Sochi's lengthy mid-lap acceleration zone – where Bottas and many others had had a similar incident in FP1.
The world champion had to slow dramatically to avoid hitting the barriers and he returned to the pits.
Bottas then took the best times in the first two sectors – which he held to the end of the session – and was 0.7s up on Hamilton's benchmark before he lost 0.5s in the final sector – including a chunk as he slid wide out of the final corner and clouted the grass bank leading onto the main straight.
Despite the wild moment, Bottas was able to complete the lap in 1m33.519s and clinch the top spot, which he held to the end of the session, staying 0.267s ahead of his teammate.
The rest of the pack then followed Mercedes in completing their qualifying simulation runs, with Ricciardo slotting into third, 1.058s slower than Bottas's best, to back up his second place in FP1 on a track that suits Renault's package.
Carlos Sainz returned to action after his crash in FP1 cost him much of the day's opening session and he took fourth for McLaren, slotting in ahead of Norris, with Sergio Perez sixth for Racing Point.
Verstappen wound up seventh as a result of his best completed lap, but he had just gone rapidly through the opening two sectors on a second run on the softs when he lost the rear of his RB16 at the exit of Turn 14 – the tight left that follows the notorious right of Turn 13 – and swung around in a plume of tyre smoke before recovering to the pitlane.
Charles Leclerc and Sebastian Vettel took eighth and 10th, either side of the second Renault of Esteban Ocon, with Alex Albon down in 12th in the other Red Bull.
After the qualifying simulations had been completed, the teams switched to the traditional long run data gathering, where both Mercedes drivers had issues.
Hamilton again locked his left-front tyre heavily at Turn 13 – this time running the medium tyres – and had to take to the runoff, albeit at a slower speed and without the threat of hitting the barriers before he carried on his way.
Bottas also had to interrupt his run on the hards as he reported something sticking in his cockpit, possibly a piece of tape, to his left hand, which disrupted the way he was able to turn right.
He came into the pits and Mercedes adjusted his cockpit in the pitlane before he carried on his long-run work.
|1|| Valtteri Bottas ||Mercedes||37||1'33.519|
|2|| Lewis Hamilton ||Mercedes||33||1'33.786||0.267|
|3|| Daniel Ricciardo ||Renault||27||1'34.577||1.058|
|4|| Carlos Sainz Jr. ||McLaren||36||1'34.723||1.204|
|5|| Lando Norris ||McLaren||33||1'34.847||1.328|
|6|| Sergio Perez ||Racing Point||35||1'34.890||1.371|
|7|| Max Verstappen ||Red Bull||30||1'35.048||1.529|
|8|| Charles Leclerc ||Ferrari||35||1'35.052||1.533|
|9|| Esteban Ocon ||Renault||28||1'35.139||1.620|
|10|| Sebastian Vettel ||Ferrari||35||1'35.183||1.664|
|11|| Pierre Gasly ||AlphaTauri||35||1'35.210||1.691|
|12|| Alex Albon ||Red Bull||31||1'35.242||1.723|
|13|| Daniil Kvyat ||AlphaTauri||37||1'35.461||1.942|
|14|| Kimi Raikkonen ||Alfa Romeo||33||1'35.516||1.997|
|15|| Nicholas Latifi ||Williams||31||1'35.563||2.044|
|16|| George Russell ||Williams||30||1'35.575||2.056|
|17|| Lance Stroll ||Racing Point||34||1'35.627||2.108|
|18|| Kevin Magnussen ||Haas||32||1'35.729||2.210|
|19|| Antonio Giovinazzi ||Alfa Romeo||36||1'36.053||2.534|
|20|| Romain Grosjean ||Haas||32||1'36.858||3.339|
|View full results|