The 23-year-old has signed a five-year contract and becomes the Ligue 1 club's fourth signing ahead of the 2017-18 season after the arrivals of Fernando Marcal, Bertrand Traore and Ferland Mendy.
Both clubs announced the transfer on Friday and Madrid thanked Mariano in a statement which read: "The club wants to show its gratitude for these years of dedication and professionalism and wishes him good luck in his next chapter."
The centre-forward, who will wear the number 11 shirt at Lyon, was with Madrid since 2011 and rose through the club's youth system to become part of the first-team squad in 2016-17.
He made his senior debut against Celta Vigo last August and made eight LaLiga substitute appearances in the club's title-winning campaign, scoring once against Deportivo La Coruna in December.
Mariano scored a further four goals across two legs of Madrid's Copa del Rey last-32 tie against Cultural Leonesa – his only two starts of the season - and leaves in search of greater first-team opportunities.
He was previously a prolific scorer for the Madrid's B team, netting 27 league goals in 2015-16.
Lyon finished fourth in Ligue 1 last season and star striker Alexandre Lacazette has been strongly linked with an exit.