The cultural flowering of Nuremberg, in the 15th and 16th centuries, made it the centre of the German Renaissance. In 1525, Nuremberg accepted the Protestant Reformation, and in 1532, the religious Peace of Nuremberg, by which the Lutherans gained important concessions, was signed there. During the 1552 revolution against Charles V, Nuremberg tried to purchase its neutrality, but the city was attacked without a declaration of war and was forced into a disadvantageous peace. At the Peace of Augsburg, the possessions of the Protestants were confirmed by the Emperor, their religious privileges extended and their independence from the Bishop of Bamberg affirmed, while the 1520s' secularisation of the monasteries was also approved.
The state of affairs in the early 16th century, increased trade routes elsewhere and the ossification of the social hierarchy and legal structures contributed to the decline in trade. Frequent quartering of Imperial, Swedish and League soldiers, the financial costs of the war and the cessation of trade caused irreparable damage to the city and a near-halving of the population. In 1632, the city, occupied by the forces of Gustavus Adolphus of Sweden, was besieged by the army of Imperial general Albrecht von Wallenstein. The city declined after the war and recovered its importance only in the 19th century, when it grew as an industrial centre. Even after the Thirty Years' War, however, there was a late flowering of architecture and culture – secular Baroque architecture is exemplified in the layout of the civic gardens built outside the city walls, and in the Protestant city's rebuilding of the Egidienkirche, destroyed by fire at the beginning of the 18th century, considered a significant contribution to the baroque church architecture of Middle Franconia.
After the Thirty Years' War, Nuremberg attempted to remain detached from external affairs, but contributions were demanded for the War of the Austrian Succession and the Seven Years' War and restrictions of imports and exports deprived the city of many markets for its manufactures. The Bavarian elector, Charles Theodore, appropriated part of the land obtained by the city during the Landshut War of Succession, to which Bavaria had maintained its claim; Prussia also claimed part of the territory. Realising its weakness, the city asked to be incorporated into Prussia but Frederick William II refused, fearing to offend Austria, Russia and France. At the Imperial diet in 1803, the independence of Nuremberg was affirmed, but on the signing of the Confederation of the Rhine on 12 July 1806, it was agreed to hand the city over to Bavaria from 8 September, with Bavaria guaranteeing the amortisation of the city's 12.5 million guilder public debt.
After the fall of Napoleon, the city's trade and commerce revived; the skill of its inhabitants together with its favourable situation soon made the city prosperous, particularly after its public debt had been acknowledged as a part of the Bavarian national debt. Having been incorporated into a Catholic country, the city was compelled to refrain from further discrimination against Catholics, who had been excluded from the rights of citizenship. Catholic services had been celebrated in the city by the priests of the Teutonic Order, often under great difficulties. After their possessions had been confiscated by the Bavarian government in 1806, they were given the Frauenkirche on the Market in 1809; in 1810 the first Catholic parish was established, which in 1818 numbered 1010 souls.
In 1817, the city was incorporated into the district of Rezatkreis (named for the Franconian Rezat river), which was renamed to Middle Franconia (German: Mittelfranken) on 1 January 1838. The first German railway, the Bavarian Ludwigsbahn, from Nuremberg to nearby Fürth, was opened in 1835. The establishment of railways and the incorporation of Bavaria into Zollverein (the 19th-century German Customs Union), commerce and industry opened the way to greater prosperity. In 1852, there were 53,638 inhabitants: 46,441 Protestants and 6616 Catholics. It subsequently grew to become the most important industrial city of Bavaria and one of the most prosperous towns of southern Germany. In 1905, its population, including several incorporated suburbs, was 291,351: 86,943 Catholics, 196,913 Protestants, 3738 Jews and 3766 members of other creeds.