"We declare and define Blessed John XXIII and John Paul II to be saints and we enrol them among the saints, decreeing that they are to be venerated as such by the whole Church," Francis said in his formal proclamation in Latin.
Relics of each man - a container of blood from John Paul II and skin from John XXIII - were placed near the altar.
The fact that the two being canonized are widely seen as representing contrasting faces of the Church has added to the significance of an event that Francis hopes will draw the world's 1.2 billion Catholics closer together after a string of sex abuse and financial scandals.
The crowd stretched back along Via della Conciliazione, the broad, half-kilometer boulevard that starts at the Tiber River.
The Mass was also attended by former Pope Benedict, who last year became the first pontiff in six centuries to step down.
His attendance gave the ceremony a somewhat surreal atmosphere created by the presence of reigning pope, a retired pope and two dead popes buried in the basilica. Francis went over to greet Benedict twice during the service.
"These were two men of courage ... and they bore witness before the Church and the world to God's goodness and mercy," Francis said in his address.
"They lived through the tragic events of that (20th) century, but they were not overwhelmed by them. For them, God was more powerful; faith was more powerful," he added.
John XXIII, who reigned from 1958 to 1963 and called the modernizing Second Vatican Council, lived through both world wars.
John Paul II, the Pole who reigned for nearly 27 years, witnessed the devastation of his homeland in World War Two and is credited by many with helping end the Cold War and bring down communism.