Malcom's second-half goal cancelled out a sixth-minute opener from Lucas Vazquez and ensured there will be plenty to play for in the return fixture on February 27.
With Lionel Messi fit enough only for a place on the bench, the onus was on Barca to show they could cope without their talisman in the first of a difficult run of fixtures this month.
Madrid went ahead with the second shot of the match, though, Vazquez twisting his body to flick the ball beyond Marc-Andre ter Stegen from Karim Benzema's drilled cross.
15 - @realmadriden have scored in each of their last 15 away games against Barcelona in all competitions (26 goals), their best scoring run away from home in #ElClasico history. Stampede. pic.twitter.com/X8gba9ZfQ5— OptaJose (@OptaJose) February 6, 2019
Malcom, starting in the cup for the fifth time this season, scuffed a glorious chance straight at Keylor Navas but was spared somewhat by the offside flag.
The Brazilian was proving a problem down the Madrid left and it was his free-kick that Ivan Rakitic headed against the crossbar, before Vinicius Junior almost set up Benzema for a tap-in on the break.
Luis Suarez saw a shot well saved by Navas after more good Malcom work, but frustrations began to build for the home side in their struggle to create clear-cut openings.
They found the equaliser 57 minutes in, however, when Sergio Ramos, having brilliantly cleared a Suarez effort off the line, allowed Malcom's strike on the rebound to fly past him and into the net, apparently convinced it was going wide.
Messi and Gareth Bale were introduced from the bench, and it was the Madrid man who missed the best chance for a winner, failing to make the most of Benzema's pass after Ter Stegen had been left stranded.
What does it mean? Madrid take slender advantage to Santiago Bernabeu
Vazquez's clever finish means Santiago Solari's side have an away goal, giving them a slight lift heading into the second leg in Madrid.
That said, with Messi likely to be fully fit by the time of the return fixture, Barca will certainly believe they are capable of at least one goal in the capital.
There was very little to split these teams - Barca edged possession, Madrid matched their opponents for attempts at goal - so there is every reason to expect a similarly tight affair next time.
Malcom a makeshift Messi
Ever-present in the cup this year, Malcom produced a performance that should put him back in contention for more regular football. He caused Marcelo plenty of problems and deserved his goal.
Coutinho cast adrift
At times, Philippe Coutinho looked like he was not involved; at others, he looked like he did not want to be. He looks a long way short of top form and confidence.
Key Opta Facts
- Real Madrid have scored in each of their last 15 away games against Barcelona in all competitions, their best scoring run away from home in El Clasico history.
- Lionel Messi has failed to score in a game in all competitions for the first time since December 2018 against Tottenham in the Champions League.
- Malcolm is the first Barcelona player to score on his debut in El Clasico since Arturo Vidal in October 2018 in LaLiga.
- Vinicius Junior attempted four shots in the first half, as many as all Barcelona players combined.
- Sergio Ramos has equaled Xavi as the player with the most appearances in El Clasico in all competitions in the 21st century (40).
The second leg takes place in three weeks' time in the capital. More immediately, Madrid make the short trip to the Wanda Metropolitano for a crucial league derby with Atletico Madrid on Saturday, while Barca head to Athletic Bilbao a day later.