Ferencvaros went hunting for a quick response, and Bamidele Yusuf spurned a golden chance in the 51st minute, blazing over the crossbar from inside the box.
The Hungarians pulled one back in the 57th minute through Kenan Kodro. He collected a Kristoffer Zachariassen pass inside the area and drilled a right-footed finish into the right corner to make it 2-1.
Real Madrid almost restored their two-goal cushion in the 61st minute. The ball dropped to Bernardo Silva in the box, but his effort struck the defence, and Arda Guler cleared the bar from range.
Back came Ferencvaros with a threat of their own in the 63rd minute. Zachariassen climbed highest to meet a Marius Corbu cross, only for Andriy Lunin to block the header and rescue Real Madrid.
The visitors kept pressing in the closing stages. Corbu fired over from outside the area in the 68th minute, and Arda Guler curled a free kick just wide of the top-left corner in the 79th.
Callum O’Dowda passed up another opening in the 82nd minute, lashing a shot from outside the box past the right post.
Szilard Szabo picked up a yellow card in the 90th minute for a heavy challenge, and Real Madrid saw out a 2-1 win.
Read also: Imminent failure: Barcelona prepare two deals within the “Alvarez” budget