Jose Ulloa fired a left-foot shot past Madrid goalkeeper Iker Casillas for Almeria's 60th-minute opener.
Esteban Granero equalized for Madrid in the 77th with a rising shot off a pass from second-half substitute Karim Benzema.
Barcelona aims to break the club's record of 27 games without a loss against a Malaga squad full of winter reinforcements.
Also, Jeremy Mathieu and Pablo Hernandez scored late goals to give Valencia a 2-0 win over Deportivo La Coruna on Sunday to strengthen its hold on fourth place in the Spanish league.
Short link: