The chain that ended in the Ninety Five Theses is administrative rather than theological at almost every link.
Albrecht of Brandenburg wanted the archbishopric of Mainz while already holding two other sees, which required a dispensation, and the fee was very large. He borrowed it from the Fugger bank. Leo, needing money for the rebuilding of St Peter's, granted both the dispensation and the right to preach the indulgence in Albrecht's territories, on terms under which the proceeds were split between Rome and the repayment of the loan. A banking agent travelled with the preachers to take the German half.
The Dominican Johann Tetzel then preached it in a way that made the transaction sound complete and mechanical, and his terms crossed into Saxony, where the elector had banned the indulgence but could not stop his subjects walking over the border.
Martin Luther's theses of 31 October 1517 attack the theology of indulgences, and they attack this arrangement specifically, asking why the pope, whose wealth exceeds that of the richest, does not build the basilica with his own money rather than with that of poor believers.
Leo's initial response was to treat it as a quarrel between religious orders. The examination by Cardinal Cajetan at Augsburg in 1518 turned on authority rather than on the doctrine. The bull Exsurge Domine of June 1520 condemned forty one propositions and gave sixty days; Luther burned it publicly. Decet Romanum Pontificem excommunicated him in January 1521, and the Diet of Worms followed in April.