The Portuguese rider triumphed in a 20-rider dash for the line after 171.6 kilometres. Saxo-Tinkoff rider Contador missed out on second to fellow Spaniard Pablo Urtasun (Euskaltel).
"It was an exciting victory - I'm really happy since it's my first this season," said Rui Costa.
"The recovery after my crash in Paris-Nice was fast. I felt already well before País Vasco, where I had a good progression day by day, and today I could make it count with this win.
"The team's strategy was the two of us, Beñat [Intxausti] and me, going after the attacks in the final climbs, and it was him who responded when Contador made his move. That's why I waited calmly for the group to bridge the gap in the finale.
"Euskaltel was pushing behind and I followed Urtasun's wheel to look for my chances into a sprint. Once Beñat and Contador were caught, I waited until the final 50 metres to jump and overcome him."
Rubén Fernández (Caja Rural-Seguros) was the lone escapee of the day, caught ahead of the second half of the route - a 25.6km circuit featuring a pair of climbs, the Category 2 Muniketagane and Cat 3 Autzagane, each of which was to be tackled three times.
José Herrada (Movistar), Contador, Intxausti (Movistar), Delio Fernández (OFM-Quinta da Lixa) and Mikel Nieve (Euskaltel-Euskadi) then went out at the commencement of the third of these circuits.
Contador and Intxausti remained ahead on the final descent into Amorebieta, but were caught by the peloton and a sprint was then inevitable.
2012 Tour de Suisse winner Rui Costa, who took a solo stage win in the 2011 Tour de France, emerged from behind Urtasun's wheel to sneak the win in a race his team captain Alejandro Valverde has won three times. Intxausti was fourth.
It continues Movistar's excellent run of form in the Basque country after Nairo Quintana won the Vuelta al País Vasco on Saturday.
The Klasika Primavera has been held since 1946.
1. Rui Costa (Movistar) 4:07.58
2. Pablo Urtasun (Euskaltel-Euskadi)
3. Alberto Contador (Saxo-Tinkoff)
4. Beñat Intxausti (Movistar)
5. José Herrada (Movistar)
6. Rory Sutherland (Saxo-Tinkoff)
7. Eduard Prades (OFM Quinta da Lixa)
8. Julien El Fares (Sojasun)
9. Edson Calderon (Colombia)
10. Shalunov Evgeny (Lokosphinx)