Lille will feel that they should have taken the lead in the 25th minute of the contest through David, with the striker having two chances in quick succession, but he was denied by Real Madrid goalkeeper Andriy Lunin on both occasions, with the second save particularly outstanding.
David is likely to be in his final season at Lille, and a number of clubs are said to be scrambling to sign him on a free transfer, with the Canadian boasting an excellent goal record, and he made the breakthrough in first-half stoppage time from the penalty spot, this time sending Lunin the wrong way.
The penalty was awarded following a VAR review, with Edon Zhegrova's free kick striking the hand of Eduardo Camavinga, and the reigning champions were behind at the break.
Kylian Mbappe - back sooner than expected from injury - was introduced just before the hour, but there was to be no response from Carlo Ancelotti's side, as they were overcome for the first time since January, with their 36-game unbeaten run coming to an end.
Los Blancos had been without a loss in all competitions since a Copa del Rey clash with Atletico Madrid on January 18, while this represents their first Champions League defeat since a 4-0 reverse to Manchester City in the second leg of their semi-final in May 2023.
Three points from two matches has left them in 17th spot in the Champions League table, while Lille occupy 18th, having also won one and lost one of their opening two games of the new-look competition.
LILLE VS. REAL MADRID HIGHLIGHTS
Jonathan David goal vs. Real Madrid (45th min, Lille 1-0 Real Madrid)
Lille make the breakthrough in the closing stages of the first period, as David converts from the penalty spot.
The penalty had been awarded by the referee following a VAR review, with Zhegrova's free kick striking the hand of Camavinga, and David made no mistake from the spot, sending Lunin the wrong way to make it 1-0.
MAN OF THE MATCH - TIAGO SANTOS
David deserves a mention in this category, with the striker impressive in the final third of the field, but the man-of-the-match award is handed to Brazilian right-back Tiago Santos.
The 22-year-old was excellent for Lille on Wednesday night, with Real Madrid struggling to get the better of a stern defence, and he was also prepared to break forward when he had the opportunity.
Santos was not the biggest name on the field in this European tie, but his overall performance from both a defensive and offensive point of view left a huge impression.
LILLE VS. REAL MADRID MATCH STATS
Possession: Lille 44%-56% Real Madrid
Shots: Lille 6-13 Real Madrid
Shots on target: Lille 3-6 Real Madrid
Corners: Lille 2-3 Real Madrid
Fouls: Lille 11-12 Real Madrid
BEST STATS
WHAT NEXT?
Real Madrid's attention will now switch back to La Liga, with Ancelotti's side travelling to Celta Vigo on Saturday evening for their final match ahead of the October international break.
Lille, meanwhile, will also be back in action on Saturday night, hosting Toulouse in Ligue 1, and they will be bidding to make it back-to-back successes in France's top flight for the first time since April.