A Symphony conventionally should have four movements in a structure of either opening - slow - dance - finale or opening - dance - slow - finale. Mahler chooses to write in opening - dance - slow - finale structure:
Gustav Mahler: Symphony No. 1 in D major
I. Introduction and Allegro comodo. (D major)
II. Scherzo. (A major)
III. A la pompes funèbres. (D minor)
IV. Finale: Allegro furioso. (F minor - D major)
Mahler chooses the key of D major for the first movement, A major for the second, D minor for the third, and F minor for the fourth. As Wikipedia says, the usage of F minor for the fourth movement was a dramatic break from conventional usage. The opening and finale movements of a symphony should be written in the original key. In this view, the finale of Mahler's Symphony No. 1, in D major, should have been written in D major, not F minor. However, it ends in D major, which is the original key.
Beethoven also had did the similar thing before:
Ludwig Van Beethoven: Symphony No. 5 in C minor
- I. Allegro con brio. (C minor)
- II. Andante con moto. (Ab major)
- III. Scherzo: Allegro. (C minor)
- IV. Finale: Allegro. (C major)
Beethoven does not choose the key of C minor for the finale, but rather C major. The triumphant and victorious mood greatly contrasts with the first and third movements, which are dark and emotionally stormy. Unlike Mahler, Beethoven never returns to the original key of C minor and is not even willing to do so - therefore, the key of C minor is never to be heard again at all.
In order to see a much more extreme case of such a rule violation, here it is:
Pytor Ilych Tchaikovsky: Symphony No. 6 in B minor
- I. Adagio - Allegro non troppo. (B minor)
- II. Valzer: Allegro con grazia. (D major)
- III. Allegro molto vivace. (G major)
- IV. Adagio lamentoso. (B minor)
Notice the word finale not being written before Adagio lamentoso! Tchaikovsky had put the slow movement as the last movement of his work! Its structure is: opening - dance - virtual finale - slow!!! It's worth pointing out the third movement is very energetic and exciting, and even concludes triumphantly. If there was no rule violation, it would look like this:
(opening - slow - dance - finale structure:)
- I. Adagio - Allegro non troppo.
- II. Adagio lamentoso.
- III. Valzer: Allegro con grazia.
- IV. Finale: Allegro molto vivace.
(opening - dance - slow - finale structure:)
- I. Adagio - Allegro non troppo.
- II. Valzer: Allegro con grazia.
- III. Adagio lamentoso.
- IV. Finale: Allegro molto vivace.
Going back to the Mahler part, the fourth movement of his Symphony No. 1 should have been D major, because the original key is D major. However, he chooses to use F minor instead - which was a dramatic break from conventional usage. However, it ends in D major via a triumphant conclusion, and the symphony ends in D major, which we would typically expect to happen.