Thomas was just able to hold off the chasers, with Sonny Colbrelli (Bahrain Victorious) very nearly catching the Welshman.
Speaking after the finish, Thomas said: “It wasn’t planned. I knew Bahrain didn’t have any guys left. I knew the last bit was a bit twisty so I just thought ‘sod it, just go for it’.
“I went with 1km to go, the boys said on the radio I had a gap, so I just went all in.
“To be honest I didn’t think I had that on the line. I just sat up two metres before to start to give it the big ‘boom’ [celebration]. Colbrelli came so fast he nearly took my arm off, but it’s really nice to get that win.”
Thomas was keen for redemption after a disappointing time trial on stage four, as he lost 23 seconds to the stage winner Alexey Lutsenko (Astana-Premier Tech) over 16km.
But with his stage win, Thomas claws back some time with a 10 second time bonus, moving into sixth place overall, 24 seconds off the race lead.
Thomas added: “[I was] definitely disappointed in yesterday. It was a combination of not great legs but also riding it badly and dying in the second half completely where you need to be strongest.
“It’s nice to bounce back.”
Thomas is now the best-placed Ineos rider, but is just two seconds ahead of team-mate Richie Porte.
The GC race continues on stage six with a tough uphill finish, featuring the Col de Porte and the Côte de la Frette in the final.
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1