Prehistory to the Kofun period
Some of the earliest signs of human habitation in the Osaka area at the Morinomiya ruins (森ノ宮遺跡 Morinomiya iseki) comprise shell mounds, sea oysters and buried human skeletons from the 6th–5th centuries BC. It is believed that what is today the Uehonmachi area consisted of a peninsular land with an inland sea in the east. During the Yayoi period, permanent habitation on the plains grew as rice farming became popular.
By the Kofun period, Osaka developed into a hub port connecting the region to the western part of Japan. The large numbers of increasingly larger tomb mounds found in the plains of Osaka are seen as evidence of political-power concentration, leading to the formation of a state.
Asuka and Nara period
The Kojiki records that during 390–430 AD there was an imperial palace located at Osumi, in what is present day Higashiyodogawa ward, but it may have been a secondary imperial residence rather than a capital.
In 645, Emperor Kōtoku built his Naniwa Nagara-Toyosaki Palace in what is now Osaka, making it the capital of Japan. The city now known as Osaka was at this time referred to as Naniwa, and this name and derivations of it are still in use for districts in central Osaka such as Naniwa (浪速) and Namba (難波). Although the capital was moved to Asuka (in Nara Prefecture today) in 655, Naniwa remained a vital connection, by land and sea, between Yamato (modern day Nara Prefecture), Korea, and China.
Naniwa was declared the capital again in 744 by order of Emperor Shōmu, and remained so until 745, when the Imperial Court moved back to Heijō-kyō (now Nara). By the end of the Nara period, Naniwa's seaport roles had been gradually taken over by neighboring areas, but it remained a lively center of river, channel, and land transportation between Heian-kyō (Kyoto today) and other destinations.
Heian to Edo period
In 1496, Jōdo Shinshū Buddhists established their headquarters in the heavily fortified Ishiyama Hongan-ji, located directly on the site of the old Naniwa Imperial Palace. Oda Nobunaga began a decade-long siege campaign on the temple in 1570 which ultimately resulted in the surrender of the monks and subsequent razing of the temple. Toyotomi Hideyoshi constructed Osaka Castle in its place in 1583.
Osaka was long considered Japan's primary economic center, with a large percentage of the population belonging to the merchant class (see Four divisions of society). Over the course of the Edo period (1603–1867), Osaka grew into one of Japan's major cities and returned to its ancient role as a lively and important port. Its popular culture was closely related to ukiyo-e depictions of life in Edo. By 1780, Osaka had cultivated a vibrant arts culture, as typified by its famous Kabuki and Bunraku theaters. In 1837, Ōshio Heihachirō, a low-ranking samurai, led a peasant insurrection in response to the city's unwillingness to support the many poor and suffering families in the area. Approximately one-quarter of the city was razed before shogunal officials put down the rebellion, after which Ōshio killed himself. Osaka was opened to foreign trade by the government of the Bakufu at the same time as Hyōgo (modern Kobe) on 1 January 1868, just before the advent of the Boshin War and the Meiji Restoration.
Osaka residents were stereotyped in Edo literature from at least the 18th century. Jippensha Ikku in 1802 depicted Osakans as stingy almost beyond belief. In 1809, the derogatory term "Kamigata zeeroku" was used by Edo residents to characterize inhabitants of the Osaka region in terms of calculation, shrewdness, lack of civic spirit, and the vulgarity of Osaka dialect. Edo writers aspired to samurai culture, and saw themselves as poor but generous, chaste, and public spirited. Edo writers by contrast saw "zeeroku" as obsequious apprentices, stingy, greedy, gluttonous, and lewd. To some degree, Osaka residents are still stigmatized by Tokyo observers in the same way today, especially in terms of gluttony, evidenced in the phrase, "Residents of Osaka devour their food until they collapse" (大阪は食倒れ "Ōsaka wa kuidaore").
19th century to present
The modern municipality was established in 1889 by government ordinance, with an initial area of 15 square kilometres (6 sq mi), overlapping today's Chūō and Nishi wards. Later, the city went through three major expansions to reach its current size of 223 square kilometres (86 sq mi). Osaka was the industrial center most clearly defined in the development of capitalism in Japan. It became known as the "Manchester of the Orient."
The rapid industrialization attracted many Korean immigrants, who set up a life apart for themselves. The political system was pluralistic, with a strong emphasis on promoting industrialization and modernization. Literacy was high and the educational system expanded rapidly, producing a middle class with a taste for literature and a willingness to support the arts. In 1927, General Motors operated a factory called Osaka Assembly until 1941, manufacturing Chevrolet, Pontiac, Oldsmobile, and Buick vehicles, operated and staffed by Japanese workers and managers. In the nearby city of Ikeda in Osaka Prefecture is the headquarters office of Daihatsu, one of Japan's oldest automobile manufacturers.
Like its European and American counterparts, Osaka displayed slums, unemployment, and poverty. In Japan it was here that municipal government first introduced a comprehensive system of poverty relief, copied in part from British models. Osaka policymakers stressed the importance of family formation and mutual assistance as the best way to combat poverty. This minimized the cost of welfare programs.
During World War II, Osaka came under air attacks in 1945 by the United States Army Air Forces as part of the air raids on Japan. On March 13, 1945, a total of 329 Boeing B-29 Superfortress heavy bombers took part in the raid against Osaka. According to an American prisoner of war who was held in the city, the air raid took almost the entire night and destroyed 25 square miles (65 km2) of the city. The U.S. bombed the city again twice in June 1945 and again on August 14, a day before Japan's surrender.