La Liga: Rayo Vallecano 0 Cordoba 1
The Andalusians travelled to Madrid having claimed just two league victories all season but were gifted three points thanks to Ba's costly error.
Rayo had the better of the first half and had the ball in the net through Alberto Bueno, only for the forward to see his effort ruled out for offside.
But it was centre-back Ba's misfortune that settled the encounter in the visitors' favour as he inadvertently turned home Florin Andone's left-wing cross at the near post in the 39th minute.
Alexandre Moreno curled a shot against the crossbar as Rayo pushed for an equaliser in the second half, however, their efforts ultimately proved in vain.
The result makes it four defeats in five league games for Rayo, who sit 11th, while Cordoba move up to 15th.