The Andover and Wilmington Railroad was incorporated March 15, 1833, to build a branch from the Boston and Lowell Railroad at Wilmington, Massachusetts, north to Andover, Massachusetts. The line opened to Andover on August 8, 1836. The name was changed to the Andover and Haverhill Railroad on April 18, 1837, reflecting plans to build further to Haverhill, Massachusetts (opened later that year), and yet further to Portland, Maine, with the renaming to the Boston and Portland Railroad on April 3, 1839, opening to the New Hampshire state line in 1840.