Real looked like being left frustrated by a well-organised home side until Mendy curled in with four minutes left.
Atalanta’s Remo Freuler was sent off after just 17 minutes for denying Mendy a clear goalscoring opportunity.
The depleted hosts did not have a single shot on target and now must score in the return leg on 16 March.
Real were without a number of key first-team players through injury including captain Sergio Ramos, Karim Benzema, Eden Hazard and Dani Carvajal and it showed for almost the entire contest.
With Atalanta sitting back after Freuler’s early red card for a cynical trip on Mendy, Zinedine Zidane’s side failed to create clear-cut chances.
Isco, playing as the furthest man forward, saw a turn and shot deflect wide, while Marco Asensio’s header and free-kick were comfortable for Pierluigi Gollini to deal with.
But with time running out, full-back Mendy earned his side a priceless away goal with a sublime curling effort from 25 yards to put Real in charge of the tie.
Atalanta will feel disappointed by conceding so late having displayed a solid defensive showing but remain without a victory at home in the Champions League this term.
Zidane, meanwhile, will be eyeing a 13th knockout-tie triumph from 14 attempts after Real progressed from the group stages for a record 24th consecutive campaign.