According to information on the Nairobi City County website, Nairobi was an uninhabited swamp until a supply depot of the Uganda Railway was built by the British in 1899, linking Mombasa to Uganda. The location of the camp was chosen due to its central position between Mombasa and Kampala. It was also chosen because its network of rivers could supply the camp with water and its elevation would make it cool enough for residential purposes for not only the thousands of Indian labourers who came to Kenya seeking to be employed to work on the railway line but also for the British settlers.

A favourable location the place soon grew, becoming the railway headquarters, which was transferred from Machakos town. The growth came with various challenges prompting the setting up of a five-member committee to look into the problems ranging from lack of street lighting, unplanned shops, improper streets, no conservancy, lack of refuse collection points and insecurity. The committee obtained its plans, marked out plots and roadways in the commercial area and sought Government’s permission to cut wood for scantlings to build the new shops and other necessary establishments.

The Nairobi Club was formed in January in 1901 and a racecourse came up at about the same time with only one school. In December, the committee was given the rights to make new by-laws for the preservation of the public health and good order within the township as well as prescribing penalties for breach of their observance.
With the use of railway by 1903, Nairobi was growing at a fast pace and new people arrived with every ship that docked at Mombasa. And in 1905, Nairobi replaced Mombasa as capital of the British protectorate expanding around administration and tourism.

In 1919, the Nairobi Township community formally became the Nairobi Municipal Council. Its boundary was extended to include surrounding part-urban settlements.
In July 1920 it was proposed that a more distinctive title be adopted for the chief of the municipality of Nairobi the capital of the protectorate. The title Mayor was suggested. It was not until 1923 that the title was officially applied.

As it grew, the town was being controlled by economic forces with no coordination of development. In an attempt to arrest the situation, a Town Planning Consultant was appointed in 1926. Jacaranda Jim Jameson from Kimberly immediately submitted his town planning report in which he proposed planting of Jacaranda trees for the beautification of the town. In March 1950, Nairobi Municipality became a city by the Royal Charter of Incorporation.

After independence in 1964, an African became Mayor and in 1984 the Nairobi City Council was dissolved to pave way for the Nairobi City Commission which governed up to 1992 when the Nairobi City Council was reconstituted. And with the promulgation of the new Constitution 2010, Dr Evans Kidero was elected as the first governor.