Lemar, who has been heavily linked with a move to England, nodded Monaco into an early lead, before Alassane Plea equalised after a video review.
Monaco moved back in front before half-time through 21-year-old Adama Diakhaby and Leonardo Jardim's French champions held on with the aid of a terrible miss by Nice midfielder Pierre Lees-Melou.
"This victory was deserved and it is very important for our fans," said Monaco coach Jardim after his side's sixth straight win.
"Diakhaby is progressing, even if he's not doing everything right, he's young and we believe in him."
The Video Assistant Referee (VAR) is being used for the rest of the competition as a test ahead of its expected arrival in Ligue 1 next season, having been used in the promotion/relegation play-off last year.
"It's good, we're losing two or three minutes in the whole game," Jardim said. "Errors will decrease, not totally, but by 80 percent."
The hosts were given a blow before kick-off as the in-form Mario Balotelli failed to regain fitness in time after suffering with glute pain.
Monaco made a fast start and took the lead in only the third minute, as Lemar found space to head in Keita Balde's cross from close range to score his third goal of an injury-hit season and send out a message to potential suitors at Arsenal and Liverpool.
The 22-year-old drilled into the roof of the net 10 minutes later, only to be denied a second goal by the linesman's flag for offside.
Nice levelled against the run of play in the 18th minute as Plea ran onto Allan Saint-Maximin's pass and slotted past Diego Benaglio at the Monaco goalkeeper's near post.
The referee checked with VAR for offside, but replays showed that Plea had timed his run to perfection before grabbing his 10th goal of the campaign.
The visitors continued to be the better side, though, and they retook the lead as forward Diakhaby sent a half-volley flying into the corner from another excellent Balde delivery.
Nice threw bodies forwards in the second half without creating many clear-cut chances, but Lees-Melou should have equalised when he headed wide with the goal gaping from only three yards out.
Runaway Ligue 1 leaders Paris Saint-Germain, who have won four straight League Cups, will look to extend their incredible 34-match winning streak in domestic cup games at Amiens on Wednesday.