The 19th century was a time of considerable expansion in Aberdeen. The increasing economic importance of Aberdeen and the development of the shipbuilding and fishing industries brought a need for improved harbour facilities. During this century much of the harbour as it exists today was built including Victoria Dock, the South Breakwater and the extension to the North Pier. Such an expensive building programme had repercussions, and in 1817 the city was in a state of bankruptcy. However, a recovery was made in the general prosperity which followed the Napoleonic wars. Improvements in street lighting came in 1824 with the advent of gas, and a vast improvement was made to the water supply in 1830 when water was pumped from the Dee to a reservoir in Union Place. An underground sewerage system was begun in 1865 to replace the open sewers which previously ran along certain streets.
The city was the headquarters of the Great North of Scotland Railway, located at 89 Guild Street, which was formed in 1846, becoming one of the constituents of the London and North Eastern Railway in 1923. The city was formerly served by Aberdeen Corporation Tramways, which closed in 1958. The city was first incorporated in 1891. At that time the church-administered central portion and the remainder of New Aberdeen were incorporated into the present city.
In 1899 the city was separated for administrative purposes from the county of Aberdeenshire, and became a "county of a city". It remained part of the lieutenancy area of Aberdeenshire. By 1901 the population was 153,000 and the city covered more than 6,000 acres (24 km²).