Belgian rider Philippe Gilbert (BMC) edged out Edvald Boasson Hagen (Sky) in a sprint finish to take the 12th stage of the Tour of Spain on Thursday.
Boasson Hagen looked set for victory in the 164.2km ride from Maella to Tarragona after being led to within sight of the line by teammate Rigoberto Uran.
But Gilbert produced a late surge to take victory on the line with Maximiliano Ariel Richeze (Lampre) claiming his third podium finish of the race in third.
In the overall classification, Italian Vincenzo Nibali (Astana) retained the leader's jersey but lost two seconds on Nicholas Roche (Saxo).
The Irishman picked up two bonus seconds in the sprint past Port Aventura to close to within 31 seconds with Alejandro Valverde (Movistar) and Chris Horner (RadioShack) remaining 46 seconds back.
Victory was Gilbert's first since winning the world road race title last year and he thanked his teammates and family for sticking by him during a difficult season.
"Firstly, I want to thank my family and all the people who have believed in me during what hasn't been the best year," he said.
"This victory is very special for me because I have always done well in Catalonia and some of my family live here.
"It was a very fast stage and in the last few kilometres I stayed at the front because I knew the finish and I knew I couldn't take risks for when the sprint started. I am very happy."
On the last stage favourable to the sprinters before a series of demanding climbs over the next week, the early pace was made by Fabricio Ferrari (Caja Rural), Romain Zingle (Cofidis) and Cedric Pineau (FDJ).
The breakaway group of three were eventually caught with around 18km to go allowing Roche to get up to claim second in the sprint past Port Aventura behind Ivan Basso (Cannondale).
But despite narrowing the gap on Nibali, Roche insisted the Giro d'Italia winner is still the strong favourite for the overall victory in Madrid come Sunday week.
"Nibali has to be the favourite. He is in extraordinary condition, he is fresh and he'll make things very difficult for us come the mountain stages."
The peloton then stayed together for a bunch sprint in the final kilometre and Boasson Hagen seemed to have it all in his favour as Uran pulled off the front with 500 metres remaining to give the Norwegian a clear run at the line.
However, Gilbert timed his surge to the finish to perfection as he came past Boasson Hagen with ease to claim a fifth career stage victory in the Tour of Spain.