We don’t precisely know. Chekhov, still in school in Taganrog, visited Moscow for the first time during the Easter holiday in 1877. His older brother Nikolai was already attending the Moscow School of Painting, Sculpture and Architecture, where Levitan was also a student. Without providing any proof, Rayfield conjectures that Levitan and Chekhov may have met during this visit. When Chekhov arrived in Moscow on August 8, 1879 to begin his medical studies at Moscow University, Levitan was living outside of Moscow, forced to leave the city as part of the expulsion of all Jews following the failed attempt to assassinate Alexander II. By the end of September, Levitan was allowed to return to Moscow.
We know that Levitan and Nikolai Chekhov had become friends because that fall Levitan showed Nikolai a painting he was working on: “Autumn Day. Sokolniki,” depicting a wide path gently curving through Sokolniki Park. Nikolai convinced Levitan that the painting was insufficiently expressive–the path was waiting for someone to inhabit it. So Levitan let Nikolai paint in a woman in a black dress walking pensively down the path.
We can presume that Levitan and Chekhov had by then become part of a common circle of students and artists, but the first strong evidence we have that they knew each other is in 1882 when Chekhov and Levitan worked together for several short-lived illustrated magazines. In any case, their friendship grew gradually over several years until the summer of 1885 when Chekhov invited Levitan to stay with him at his dacha at Babkino and paint the surrounding countryside.