Portugal needed a win away at Luxemburg to be sure of qualification as Serbia needed a win against Ukraine and hope Portugal drop points.
They did not disappoint as they beat Luxemburg 2-0, while Serbia drew 2-2 with Ukraine.
After a sloppy start, Portugal opened scoring on 39th minute through Bruno Fernandes.
Fernandes scored with a brilliant shot into the bottom right corner after being released inside the box by a superb lofted pass from Bernardo Silva.
Ronaldo scored in the 86th minute to seal victory for Portugal and hit 99th goal for his country.
Ronaldo had reacted quickly in the penalty area and scored with aplomb, giving the goalkeeper no chance.