The beginnings of the Subway came from various excursion railroads to Coney Island and elevated railroads in Manhattan and Brooklyn. At that time, New York County (Manhattan Island and part of the Bronx), Kings County (including the Cities of Brooklyn and Williamsburg) and Queens County were separate municipal entities.
In New York, competing steam-powered elevated railroads were built over major avenues. The first elevated line was constructed in 1867-70 by Charles Harvey and his West Side and Yonkers Patent Railway company along Greenwich Street and Ninth Avenue (although cable cars were the initial mode of transportation on that railway). Later more lines were built on Second, Third and Sixth Avenues. None of these structures remain today, but these lines later shared trackage with subway trains as part of the IRT system.
In Kings County, elevated railroads were also built by several companies, over Lexington, Myrtle, Third and Fifth Avenues, Fulton Street and Broadway. These also later shared trackage with subway trains, and even operated into the subway, as part of the BRT and BMT. Most of these structures have been dismantled, but some remain in original form, mostly rebuilt and upgraded. These lines were linked to Manhattan by various ferries and later the tracks along the Brooklyn Bridge (which originally had their own line, and were later integrated into the BRT/BMT).
Also in Kings County, six steam excursion railroads were built to various beaches in the southern part of the county; all but one (the Manhattan Beach Line) eventually fell under BMT control.