During the first years of the Qing Dynasty, the isolated village housed nine families, thus the village would request "nine portions" every time shipments arrived from town. Later Kau-hun (meaning "nine portions" in Hokkien) would become the name of the village.
Despite the earliest reference to the production of gold in the island dating to 1430, and multiple rediscoveries by early inhabitants, visiting Japanese, Dutch occupiers, and Koxinga's retainers, awareness of the wealth of Taiwan's gold districts did not develop until the late Qing era. In 1890, workmen discovered flakes of gold while constructing the new Taipeh-Kelung railway, and in 1893 a rich placer district was discovered in the hills of Kau-hun that produced several kilograms[a] of gold a day. In the next year, the promise became greater than ever after a Chinese "expert" with experience gained in California found gold-bearing quartz in the said hills.
The resulting gold rush hastened the village's development into a town, and reached its peak during the Japanese era. In The Island of Formosa, Past and Present (1903), American diplomat James W. Davidson wrote, "Kyu-fun [Kau-hun] is as odd looking a settlement as one could find. [...] never before has the writer seen so many houses in such a small space. Some appear to be partially telescoped in adjoining buildings, other standing above as though unable to force their way to the group, and each structure seems to be making a silent appeal to its neighbor to move over." Water ran "in many small streams, directed so as to provide each building with a little rivulet, passing sometimes by the doorway or even over the floor of the building." The claim was owned by the Fujita Company, the first Japanese company to mine quartz in Taiwan and which occasionally made an income of a few thousand yen per month from the Kau-hun gold operations.
Many present features of Jiufen reflect the era under Japanese colonization, with many Japanese inns surviving to this day. During World War II, a POW camp named Kinkaseki was set up in the village, holding Allied soldiers captured in Singapore (including many British) who worked in the nearby gold mines. Gold mining activities declined after World War II, and the mine was shut off in 1971. Jiufen quickly went into decline, and for a while the town was mostly forgotten.
In 1989, Hou Hsiao-hsien's A City of Sadness, the first film to touch on the February 28 Incident, then a taboo subject in Taiwan, won acclaim around the world. As a result, Jiufen, where the film was set, revived due to the film's popularity. The nostalgic scenery of Jiufen as seen in the film, as well as appearances in other media, charmed many people into visiting Jiufen. For the beginning of the 1990s, Jiufen experienced a tourist boom that has shaped the town as a tourist attraction. Soon retro-Chinese style cafés, tea houses, and souvenir stores bearing the name "City of Sadness" were built.
Jiufen also became popular in 2001 due to its resemblance to the downtown in the Japanese anime movie Spirited Away by Studio Ghibli. Jiufen soon attracted Japanese tourists. Many Japanese travel magazines and guide books about Taiwan introduced Jiufen. It became a must visit place among Japanese tourists. However, Miyazaki himself denied that Jiufen was the model city of the movie. 
At present, Jiufen is a renowned tourist attraction representative of Taiwan. It draws many tourists from Taipei during the weekends.