Vuelta a España - Gilbert takes Vuelta solo sprint
Filippo Possato claimed third place on the 200km stage from Piedrahita to Toledo.
The Omega Pharma rider timed his burst to perfection on the slight uphill finish.
Farrar of Garmin did all he could to close the gap on Gilbert but did not have enough to threaten a stage win.
Going into the final kilometres Luis Sanchez and Carlos Barredo looked to have jumped away from the field but HTC's Matt Goss closed the gap.
The Australian then himself leapt away and was joined by Gilbert, who sensed an opportunity to win and ended up going alone.
Farrar reacted too late despite a good lead-out from David Millar.
Instead of attacking on the earlier category two climb of Puerto de Chia the quartet came together just one kilometre after the summit.
With the peloton happy to sit back and conserve energy the gap grew to more than 10 minutes with 145km remaining.
But slowly the main bunch reacted and slowly reeled in the escapees with Footon, HTC-Columbia, Katusha and Liquigas leading the way.
Midway through the stage Saxo Bank's 2009 time-trial world champion Fabian Cancellara withdrew from the race.
Rumours then flooded through the field as to whether he would race at the World Championships in Melbourne later this year. No comment was forthcoming from Saxo Bank.
The Vuelta finishes in Madrid on September 19.