Farrar, who revealed he had thrown up repeatedly during Tuesday's stage, bounced back in style to win the bunch sprint and claim a victory he had not dared hope for on the 198.8 kilometer run from Guadix to Lorca.
"It's a surprise win," the Garmin rider told reporters. "I vomited six times during Tuesday's stage and felt really bad.
"A victory in the Tour of Spain is always a massive achievement, but managing to win today is even more special.
"It's also very motivating for the World Championships. I think I'll have a good chance there."
Philippe Gilbert of Belgium maintained his lead in the overall standings, 10 seconds ahead of Spain's Igor Anton, after what he described as an "easy day."
Before the start of the race, the peloton held a minute's silence as tribute to double Tour de France winner Laurent Fignon, who died on Tuesday from cancer.
