Wissam Ben Yedder broke the deadlock in the 26th minute after slotting under Kika Casilla.
However, the hosts would extend their advantage just before half-time thanks to some calamity defending by Madrid.
Two defenders crashed into one another trying to block a squared ball to Steven N'Zonzi in the box, leaving the midfielder free to pass to Layun who fired into the roof of the net to make it 2-0.