Wearing only pink, Contador (Saxo Bank) completed the 26 kilometre course around sunny Milan 36 seconds down on Garmin-Cervelo's Millar, who set a strong time of 30 minutes 13 seconds over a flat but technical route.
Italy's Michele Scarponi (Lampre) protected his second place on the podium despite finishing 10 seconds slower than compatriot Vincenzo Nibali (Liquigas) in the decisive time trial.
Scarponi completed the three week race 6:10 slower than winner Contador, with Nibali taking third place at 6:56.
Frenchman John Gadret (AG2R-La Mondiale), an unfancied time trial rider, limited his losses to secure a fourth place in the overall standings, 10:17 down on the maglia rosa, while Spain's Joaquim Rodriguez (Katusha) completed the top five, 11:05 down.
Riding the course almost two hours earlier than the top GC contenders, 34-year-old Millar put on a stellar display of time trialling, looking comfortable and assured throughout his ride.
Millar held the best time at the first intermediate check after 8.9km until Contador, riding last as race leader, topped his effort by a slender one second. The Scot had a small slump over the second third of the course, coming over the 18.1km check six seconds down on Dane Alex Rasmussen (HTC-Highroad).
But a superlative final third saw Millar claw back the time lost to Rasmussen, who he beat by seven seconds across the line.
It was Millar's 10th stage win on a Grand Tour, but his first individual scalp on the Giro, three years after picking up the team time trial stage in the 2008 edition of the race.
Assured of the overall victory, 28-year-old Contador, the 2008 winner, took his foot off the gas as he entered the centre of Milan, dropping to 17 seconds behind Rasmussen's benchmark time at the 18.1km check.
Entering the final straight, Contador rode the final 150 metres of the 94th Giro d'Italia with his arms aloft as he celebrated a career sixth Grand Tour victory.
Having asserted his authority as early as stage 9 of the race, when he picked up the pink jersey after riding solo to victory atop Mount Etna, Contador looked in complete control throughout the race.
Two stage victories and four second-place finishes showed just why the Spaniard is regarded as the best rider of his generation.
However, his critics will still point to the up-coming summer hearing with the Court of Arbitration for Sport, which will decide Contador's fate after the International Cycling Union (UCI) and the World Anti-Doping Agency (WADA) appealed against the Spanish cycling federation's decision to clear the former Astana rider after he tested positive for the banned anabolic agent clenbuterol during last year's Tour de France.