The Buffalo and State Line Railroad was incorporated October 13, 1849, and opened January 1, 1852, from Dunkirk, NY west to Pennsylvania. The rest of the line from Dunkirk to Buffalo opened on February 22. The Erie and North East Railroad was chartered April 12, 1842, to build the part from the state line west to Erie, PA, and opened on January 19, 1852. On November 16, 1853, an agreement was made between the two railroads, which had been built at broad gauge, to relay the rails at to match the Franklin Canal Company's railroad (see below) on the other side of Erie, and for the Buffalo and State Line to operate the Erie and Northeast. This would result in through passengers no longer having to change trains at Erie, and on December 7, 1853, the Erie Gauge War began between the railroads and the townspeople. On February 1, 1854, the relaying was finished and the first train passed through Erie. On May 15, 1867, the two companies between Buffalo and Erie merged to form the Buffalo and Erie Railroad.