Shakespeare's Hamlet was the inspiration for two works by Pyotr Ilyich Tchaikovsky: the overture-fantasia Hamlet, Op. 67, and incidental music for the play, Op. 67a.
Tchaikovsky wrote the Hamlet overture-fantasia, Op. 67, between June and 19 October 1888, overlapping the scoring of his Fifth Symphony.
The idea of a Hamlet overture had first occurred to Tchaikovsky in 1876, as outlined in his plans in a letter to his brother Modest. At that time, he conceived it in three parts:
1. Elsinore and Hamlet, up to the appearance of his father's ghost
2. Polonius (scherzando) and Ophelia (adagio), and
3. Hamlet after the appearance of the ghost. His death and Fortinbras.
However, by 1888 he had altered these notions. The actor Lucien Guitry asked him to write some incidental music for a production of Shakespeare's play, to which Tchaikovsky agreed. The planned performance was cancelled, but Tchaikovsky decided to finish what he had started, in the form of a concert overture. There is no musical enactment of the events of the play, or even a presentation of the key characters. The work adopts the same scheme he used in his other Shakespeare pieces, the fantasy-overture Romeo and Juliet (1869, revised 1870 and 1880) and the symphonic fantasy The Tempest (1873), in using certain characteristics or emotional situations within the play. The essence of the work is the brooding atmosphere depicting Elsinore, but there is an obvious love theme, and a plaintive melody on the oboe can be seen to represent Ophelia.
What makes "Hamlet" unique from other works of Tchaikovsky fantasy is the lack of a structural development. The standard form of this music has an exposition, a development, and concludes with a recapitulation. Tchaikovsky did not clearly emphasize a development section in "Hamlet."
The Hamlet overture-fantasia was dedicated to Edvard Grieg, whom Tchaikovsky had met in Leipzig in early 1888 on the same occasion that he met Johannes Brahms. He described Grieg as "an extraordinarily charming man".
The Symphony No. 5 was premiered on 17 November 1888, and the Hamlet overture-fantasia had its first performance a week later, on 24 November. Both performances were in Saint Petersburg, and Tchaikovsky conducted both of them. While Hamlet was not a great success, it still received a better initial reception than the symphony did, but it has subsequently assumed a lower profile in Tchaikovsky's works.
Excerpts from the score were used in the 2005 ballet Anna Karenina, choreographed by Boris Eifman.
Lucien Guitry again asked Tchaikovsky to write incidental music for Hamlet. This time, it was for a benefit production on 21 February 1891 at the Mikhaylovsky Theatre in Saint Petersburg, and it was to be Guitry's farewell performance. Tchaikovsky started work on the incidental music on 13 January, but found it difficult. He was exhausted from completing The Queen of Spades, which had premiered to a triumph in December 1890. Also that month, his patroness Nadezhda von Meck had severed her connection with him. He was also suffering an affliction of the right hand. For these reasons he had cancelled his conducting engagements in Mainz, Budapest and Frankfurt, and retired for rest and recuperation to Frolovskoye.
For the overture, he used the earlier stand-alone Hamlet overture-fantasia Op. 67, but in a shortened form. In the 16 other numbers, as well as writing some new music, he also used material from the incidental music to The Snow Maiden, Op. 12 (1873), from the alla tedesca movement of the Third Symphony (1875), and from the Elegy for Ivan Samarin (1884). The writing was finished by 3 February. Tchaikovsky travelled from Moscow to attend the performance in Saint Petersburg. He enjoyed the performance for the acting, but he never thought much of the music he had produced, and refused permission for it to be used in a later production in Warsaw.