The area around present-day Yokosuka city has been inhabited for thousands of years. Archaeologists have found stone tools and shell middens from the Japanese Paleolithic period and ceramic shards from the Jomon and Kofun periods at numerous locations in the area. During the Heian period, local warlord Muraoka Tamemichi established Kinugasa Castle in 1063. He became the ancestor of the Miura clan, which subsequently dominated eastern Sagami Province for the next several hundred years. The Miura clan supported Minamoto no Yoritomo in the foundation of the Kamakura shogunate, but were later annihilated by Houjou Tokiyori in 1247. However, the family name was reassigned to a supporter of the Houjou clan, and the Miura continued to rule Miura Peninsula through the Muromachi period until their defeat at Arai Castle in a 1518 attack by Houjou Souun. Following the defeat of the Late Houjou clan at the Battle of Odawara, Toyotomi Hideyoshi transferred Tokugawa Ieyasu to take control over the Kantou region, including Yokosuka in 1590.
The adventurer William Adams (inspiration for a character in the novel Shougun), the first Briton to set foot in Japan, arrived at Uraga aboard the Dutch trading vessel Liefde in 1600. In 1612, he was granted the title of samurai and a fief in Hemi within the boundaries of present-day Yokosuka, due to his services to the Tokugawa shogunate. A monument to William Adams (called Miura Anjin in Japanese) is a local landmark in Yokosuka.
During the Edo period, Yokosuka tenryou territory controlled directly by the Tokugawa shogunate, but administered through various hatamoto. Due to its strategic location at the entrance to Tokyo Bay, the Shogunate established the post of Uraga Bugyou in 1720, and all shipping into the bay was required to stop for inspection. As concerns over the increasing number of incursions by foreign vessels and attempts to end Japan's self-imposed national seclusion policy, the Shogunate established a number of coastal artillery batteries around Yokosuka, including an outpost at outsu in 1842. However, despite these efforts, in 1853, United States naval Commodore Matthew Perry arrived in Tokyo Bay with his fleet of Black Ships and came ashore at Kurihama, in southern Yokosuka, leading to the opening of diplomatic and trade relations between Japan and the United States. The Kanrin Maru sailed from Yokosuka in 1860 with the first Japanese diplomatic embassy to the United States in 1860.
During the turbulent Bakumatsu period, the Shogunate selected Yokosuka as the site for a modern naval base, and hired the French engineer Leonce Verny in 1865 to oversee the development of shipbuilding facilities, beginning with Yokosuka Iron Foundry. Yokosuka Naval Arsenal became the first modern arsenal to be created in Japan. The construction of the arsenal was the central point of a global modern infrastructure, that was to prove an important first step for the modernization of Japan's industry. Modern buildings, the Hashirimizu waterway, foundries, brick factories, and technical schools to train Japanese technicians were established.