The Symphony No. 38 in D major, K. 504, was composed by Wolfgang Amadeus Mozart in late 1786. It was premiered in Prague on January 19, 1787, during Mozart's first visit to the city. Because it was first performed in Prague, it is popularly known as the Prague Symphony. Mozart's autograph thematic catalogue records December 6, 1786, as the date of completion for this composition.
Other works written by Mozart about contemporary with this symphony include the Piano Trio in B♭, K. 502 (completed November 18, 1786), the Piano Concerto No. 25, K. 503 (completed December 4, 1786), and scena and rondò Ch'io mi scordi di te?, K. 505, for soprano and orchestra (completed December 26, 1786).
Although Mozart's popularity among the Viennese waxed and waned, he was consistently popular among the Bohemians and had a devoted following in Prague. In spite of the fact that the Symphony No. 38 was first performed in Prague, it is not certain that it was actually written for Prague. Much of the confusion surrounds the chronology of its inception. It is clear that Mozart was invited to Prague on the strength of the reception of his opera Le nozze di Figaro during the 1786–87 winter season of the National Theatre (now called the Estates Theatre) in Prague. It is not known, however, when the run started, possibly in November 1786, possibly in December. No mention of the overwhelming success of Le nozze di Figaro is recorded in the Prague press until December 11, 1786, five days after the symphony was completed. It is certain that the opera's run before that week, but there is no documentation to confirm when. It is known from a letter of Leopold Mozart written in January 1787 that Mozart was invited to Prague by a group of musicians and patrons. It is possible that this invitation came through long before Le nozze di Figaro was actually performed in Prague, perhaps during the time of rehearsals, when the brilliance of the music would have been recognized already by the musicians playing it. It is also possible that the Prague Symphony was intended to be performed for the Advent instrumental concerts given in Vienna in December 1786 along with the Piano Concerto No. 25, but all that can be established for certain is that it was not performed in Vienna before it was performed in Prague.