The piece was written in Clarens, a Swiss resort on the shores of Lake Geneva, where Tchaikovsky had gone to recover from the depression brought on by his disastrous marriage to Antonina Miliukova. He was working on his Piano Sonata in G major but finding it heavy going. Presently he was joined there by his composition pupil, the violinist Iosif Kotek, who had been in Berlin for violin studies with Joseph Joachim. The two played works for violin and piano together, including a violin-and-piano arrangement of Édouard Lalo's Symphonie espagnole, which they may have played through the day after Kotek's arrival. This work may have been the catalyst for the composition of the concerto. He wrote to his patroness Nadezhda von Meck, "It [the Symphonie espagnole] has a lot of freshness, lightness, of piquant rhythms, of beautiful and excellently harmonized melodies.... He [Lalo], in the same way as Léo Delibes and Bizet, does not strive after profundity, but he carefully avoids routine, seeks out new forms, and thinks more about musical beauty than about observing established traditions, as do the Germans." Tchaikovsky authority Dr. David Brown writes that Tchaikovsky "might almost have been writing the prescription for the violin concerto he himself was about to compose."
Tchaikovsky made swift, steady progress on the concerto, as by this point in his rest cure he had regained his inspiration, and the work was completed within a month despite the middle movement getting a complete rewrite (a version of the original movement was preserved as the first of the three pieces for violin and piano, Souvenir d'un lieu cher). Since Tchaikovsky was not a violinist, he sought the advice of Kotek on the completion of the solo part. "How lovingly he's busying himself with my concerto!" Tchaikovsky wrote to his brother Anatoly on the day he completed the new slow movement. "It goes without saying that I would have been able to do nothing without him. He plays it marvelously."
Tchaikovsky wanted to dedicate the concerto to Iosif Kotek, but felt constrained by the gossip this would undoubtedly cause about the true nature of his relationship with the younger man. (They were almost certainly lovers at one point, and Tchaikovsky was always at pains to disguise his homosexuality from the general public. In 1881, he broke with Kotek after he refused to play the Violin Concerto, believing it was poorly received and would do damage to his budding career.) However, he did dedicate to Kotek the Valse-Scherzo in C for violin and orchestra, written in 1877, on its publication in 1878.