Now a specialty of Nagasaki, the cake was brought to Japan by Portuguese merchants in the 16th century. The name is derived from PortuguesePão de Castela, meaning "bread from Castile". Castella cake is usually sold in long boxes, with the cake inside being approximately 27 cm long. It is somewhat similar to Madeira cake, also associated with Portugal, but its closest relative is pão-de-ló, also a Portuguese cake.
There are similar types of sponge cakes named after the same fashion, in French: Pain d'Espagne, in Italian: Pan di Spagna, in Portuguese: Pão de Espanha, in Romanian: Pandişpan, in Bulgarian: пандишпан, in Greek: Παντεσπάνι, in Turkish: Pandispanya (Castile is a former kingdom of Spain comprising its central provinces, thus Pain d'Espagne and other variants are quasi-synonymous to "bread from Castile").
In the 16th century, the Portuguese reached Japan and soon started trade and missionary work. Nagasaki was then the only Japanese port open for foreign commerce. The Portuguese introduced many then-unusual things, such as guns, tobacco, and pumpkins. The cake could be stored for a long period of time, and so was useful for the sailors who were out on the sea for months. In the Edo Period, in part due to the cost of sugar, castella was an expensive dessert to make despite the ingredients sold by the Portuguese. When the Emperor of Japan's envoy was invited, the Tokugawa Shogunate presented the Castella. Over the years, the taste changed to suit Japanese palates.