Chronologically, Railgun comes first. Then near the middle of Railgun (the Level Upper Arc), the events and timeline start to converge with Index.
For an example, in episode 17 of the Railgun anime, Komoe-sensei mentions how she likes all her students, even the ones that blow up her roof, which is probably a reference to when Index used Dragon's Breath (episode 6 of Index).
The manga gives a better frame of reference, since it gives a exact date (July 16th).
So the events in Railgun begin 4 days before the Index novel (July 20th), where Touma first meets Index. Touma meets Mikoto on the eve of July 19th.
According to the TV Tropes:
The anime, however, violates this by adapting events from Volume 8 of the novels into the anime's first episode. As it stands, Chapters 18 to 39 occur around the time of Volume 3 in the novels, Chapter 40 is around volume 5, Chapters 41-42 and around volume 8 and Chapters 43-current take place around volume 9.