The reigning European champions were made to work for their points at the Santiago Bernabeu but eventually came out on top 2-1 in their Group F opener despite trailing as late as the 89th minute.
Lisbon took the advantage only minutes into the second half when an intended Bryan Ruiz through ball deflected back into the path of the onrushing Bruno Cesar who slotted an inch-perfect low left-footed effort beyond the outstretched hand of Kiko Casilla, nestling the ball inside the far post.
The goal stunned the Spanish giants who were forced into action in search of at least an equaliser as the minutes ticked on.
Ronaldo, who had tried his luck from range in the first half but was unable to beat Portugal teammate Rui Patricio, was next denied by the upright when he had the goal at his mercy when things were becoming more frantic.
But the superstar held his nerve at the end of a tough contest by producing a quite fabulous free-kick from distance to level it up for Los Blancos in the final minute of regular time.
The celebrations were stifled by Ronaldo who paid homage to the club that gave him his start as a skinny teenager almost 15 years ago.
This piece of artistry influenced Zinedine Zidane's men to go after the win, which seemed out of grasp moments earlier, and it came in the 94th minute when Alvaro Morata got on the end of a delightful cross from James Rodriguez to powerfully head home the winner.
The goal sent the Real fans into raptures who provided a deafening sound at the Bernabeu as their champions kicked off their title defence with a spirited triumph over Jorge Jesus' luckless Sporting side.
Madrid will now get set to travel to Borussia Dortmund, who beat Legia Warsaw 6-0, on September 27 as Sporting look to recoil when hosting the hapless Poles on the same date.
2016/17 UEFA Champions League - Group F
Santiago Bernabéu, Madrid, Spain - 72,179