The Movistar rider headed into the last day of racing with a 14-second lead over Schleck, which he managed to protect despite a series of attacks from the Luxembourger and his RadioShack-Nissan team-mates, the Portuguese able to mark his rival effectively to the finish.
The stage was won by Astana’s Tanel Kangert after the Estonian managed to outlast Frenchman Jeremy Roy as the pair broke clear in the final climb.
Kangert finished two seconds clear of the FDJ-Big Mat rider for the biggest victory of his career, with Matteo Montaguti of AG2R La Mondiale third on the day 31 seconds behind.
But the main action was one minute and 46 seconds behind, where the yellow jersey chasing pack failed to fragment thanks to some determined pushes from Costa and team-mate Alejandro Valverde.
Schleck and Levi Leipheimer – who finished third overall – attempted to spread the peloton but were constantly reeled back by Costa, who seemed determined not to give up a single second to either man.