Cavendish went early but was overhauled by Farrar
Mark Cavendish was beaten in a sprint finish for the second time in three days in the Tour of Spain.
Cavendish, who was pipped by Belarusian Yauheni Hutarovich on Monday, took to the front early in the sprint to end the 198.8km fifth stage into Lorca.
But he was passed by Team Garmin's sprinter Tyler Farrar and Euskaltel's Koldo Fernandez and finished third.
Belgian Philippe Gilbert retained the lead in the general classification, by 10 seconds from Spain's Igor Anton.
Cavendish, 25, is making his debut in the Vuelta a Espana but is joined by only one of the HTC-Columbia line-up that helped him win five stages of the Tour de France in July - Austrian Bernhard Eisel.
In the two sprint finishes so far, Cavendish has missed the final lead-out that Matt Renshaw provided in France, until the Australian was ejected from the race for dangerous behaviour.
It was Farrar's fourth stage win in one of the three major Tours, after two stage victories in the Giro d'Italia this year and one in the Tour of Spain in 2009.
He was forced to drop out of the Tour de France in July because of a wrist injury but successfully defended his title in the Vattenfall Cyclassics one-day race in Germany on 15 August.
"It was a surprise for me today, I was ill yesterday, I had a bad night," he revealed. "This morning I was a little better and I produced some adrenaline at the finish."
Thursday's sixth stage takes the riders 151km from Caravaca de la Cruz to Murcia and features one second category climb towards the end followed by a downhill stretch to the finish.
The 21-stage 65th edition of the Vuelta ends in Madrid on 19 September.