The application to form "The East and West Yorkshire Junction Railway" was made in November 1845, and the company was incorporated by Act of Parliament on 16 July 1846, this authorising £200,000 of capital and £66,600 of debt. The line connected the Great North of England Railway near York to the Leeds and Thirsk Railway at Knaresborough, with a route length of about. The line branched from the GNE from York station and passed through Poppleton, Hessay, Marston Moor, Hammerton, Cattal, Allerton and Goldsborough to Knaresborough. The line's engineer was Thomas Grainger and the main stations were built by Samuel Atack to Grainger's designs. Construction began in 1847, works including a tunnel under part of Knaresborough and a viaduct over the River Nidd. The line was double tracked with a length of. On 11 March 1848 the nearly completed viaduct over the Nidd collapsed, and a temporary wooden station was constructed east of Knaresborough on Hay-A-Park Lane to allow the line to partially opened on 30 October 1848. Originally backed by George Hudson, the company directors made an agreement with the rival L&TR, which had begun proceedings to absorb the company. However, after the L&TR backed out of the arrangement in the middle of 1848, the directors returned to Hudson and made arrangements for the YN&B to work the line. After 1849 the line was worked with lighter engines from E. B. Wilson with payment on a worked miles basis, plus a percentage of revenue. The York and North Midland Railway took over the line in July. The replacement four arch stone double track viaduct over the Nidd was completed at a cost of £9,803 and the section over the River Nidd connecting to the L&TR was opened on 1 October 1851. Knaresborough station opened the same year, completing the route to Harrogate made by the 1.75 mile Leeds Northern extension from Harrogate to Knaresborough that also completed in 1851. From October 1851 the line also used the L&TR Starbeck station in Harrogate. Formal application to merge the railway with the Y&NMR was made in 1851 and the Act passed on 28 May 1852. On 1 April 1875 a single track line from Boroughbridge was opened, joining the line east of the town at Knaresborough Junction.