Javi Espinosa's 89th-minute penalty was enough to secure struggling Barcelona B a win away to Cordoba in the Segunda Division.
The visitors enjoyed the greater possession and took the lead just after the half-hour mark thanks to a Dani Nieto strike.
Cordoba looked to have snatched a draw when Mendi bagged an equaliser nine minutes from time.
However, Espinosa's successful spot kick was enough to give the Catalan outfit three points and bring to an end a run of three straight defeats, including last week's loss at Las Palmas.
The defeat dents Cordoba's push for the playoff places, leaving them eighth in the table.