The name describes the land. A sandbar ran out from the shore, and seen from the sea it lay sideways: yoko for sideways, hama for beach. A small fishing village stood on it through the Edo period, when Japan kept foreigners at a distance.
That ended when Commodore Perry brought American warships in 1853 and 1854 and demanded that Japan open ports. The first choice was Kanagawa-juku, on the Tōkaidō highway between Edo and Kyoto. The shogunate thought that too close for comfort and built the port across the inlet, in the fishing village. It opened on 2 June 1859.
Foreigners took the low ground of Kannai, whose name means inside the barrier and which a moat enclosed. Later the settlement climbed to the Yamate heights, which English speakers called the Bluff. Chinese traders came too. The town collected firsts for Japan: an English-language newspaper in 1861, beer and ice cream made locally in 1865, and foreign sports arrived with the residents: racing horses from 1862, then cricket (1863) and rugby (1866).
Silk became the port's trade after the Meiji Restoration of 1868, with Britain as the main buyer. Japan's first railway was built in 1872 to link Yokohama with Shinagawa and Shinbashi in Tokyo, and the first gas street lamps went up the same year. The city was incorporated in 1889. By 1899, when the foreign enclaves lost their extraterritorial status, it was the most international city in Japan. Factories spread over reclaimed land to the north towards Kawasaki, and that strip grew into the Keihin Industrial Area.
On 1 September 1923 the Great Kantō earthquake destroyed much of the city. Police counted 30,771 dead out of a population of 434,170. In the panic that followed, rumours of rebellion and sabotage set off mobs that murdered many Koreans, an event called the Kantō Massacre. Yokohama was rebuilt, and the earthquake rubble became new waterfront land.
The second destruction came from the air. On the morning of 29 May 1945, B-29 bombers firebombed the city for just over an hour, killing an estimated 7,000 to 8,000 people and leaving 42 percent of the city in ruins. During the American occupation the port became a major transshipment base, busiest during the Korean War.
The trams and trolleybuses were scrapped in 1972, the year the first subway line opened. In 1983 work began on Minato Mirai 21, an urban development on reclaimed land.