The tale is told that the great Japanese warlord Toyotomi Hideyoshi was touring the countryside near the town of Himeji one day late in the 16th century, in search of building materials for a new castle. An old woman came forward with a millstone -- a costly piece of property in those days. "If you think this might be of use ...," she said. Her example led local people to redouble their efforts. To show thanks, Hideyoshi had her stone placed high in the wall of the castle's central tower, where visitors can see it today.

Factual or not, the tale recalls the tremendous national sacrifice that went into castle-building in Japan during the late 16th and early 17th centuries. As in ancient China with the Great Wall and Egypt with the Pyramids, whole generations of Japanese, poor and rich alike, gave heavily of their labor and possessions to erect what would become great monuments to the age. Close to 50 castles went up in the years 1596 to 1615 alone.

They dwarfed the largest castles medieval Europe produced. They contained some of the most graceful, durable and massive stonework found anywhere in the world. Their soaring central towers, or tenshu, brought to new perfection and form an architecture of timber and terra-cotta tile that had begun evolving centuries earlier in Buddhist temples.

With his castle each lord sought to demonstrate, in grander fashion than his neighbor, the scope of his wealth and personal glory. Tiled towers rose higher and higher, dominating the lush countryside for miles around and, the occupants hoped, warning off anyone who might mount a challenge. (Paradoxically, the great towers were often the first thing to go up in smoke during sieges, despite best efforts at fireproofing.)

Unfortunately, few castles survive in their original state. Himeji's Shirasagi-jo, the Castle of the White Heron, is one of the few that time has hardly touched and where visitors can wander through the same wooden halls, gates and towers that once were filled with lords and samurai. But in many other Japanese cities, remnants of other castles survive -- enough to give the traveler a feeling for their years of glory.

The castles of Japan were constructed as fighting citadels during a period of relentless war. But in that role they became obsolete almost overnight, as peace, 250 years of it, took hold in Japan early in the 17th century. From then on, they functioned as symbols of power and of the feudal order itself, with the status of the various social classes reflected in the distance from the tower to homes.

The Imperial Palace complex of Tokyo, a 568-acre oasis of green and solitude in the core of the city, was the setting for Edo Castle, a gigantic structure that served as the stronghold for the Tokugawa shoguns. Tokugawa Ieyasu, the man who established Japan's long peace, began building Edo Castle in 1593 as headquarters for himself and his descendants, who ruled Japan until pressure from the West brought their overthrow in 1868 and set the country on the road to modernization. The castle was almost completely destroyed by firebombs in 1945; it was reconstructed in 1968, but it is only a fraction of its original size.

The castle was designed to be so huge in part to impoverish the lords that Ieyasu had subdued and render them less able to make trouble. First, the lords of western Japan contributed, based on size of estates and income. Three thousand boats were employed to bring stones north from the Izu peninsula, some bearing only one at each trip. In later years, the lords of eastern Japan had their turn at being fleeced. Accounts from the time say that Ieyasu himself often inspected the construction, stopping for refreshment in tea houses placed along the walls for the purpose.

On the walls were built -- of wood, tile and thick layers of fire-proofing plaster -- a vast collection of watch towers, parapets, storehouses and guardhouses. The castle had 38 gates at its height. The central tower, black, five glorious stories of tile and highly crafted wood, rose 143 feet above the hon-no-maru, or central fortress.

A walk is easily the best way to appreciate the beauty of its moats and stonework. If you're good for three miles, it will also bring home the size of Edo Castle, and even then you will not have fully circled it. A good starting point is Sakuradamon, Gate of the Cherry Tree Field, on the south side, at the Kasumigaseki government office district. Pass through the gate and its massive, metal-plated doors and walk, keeping the moats on your left.

Japanese castle walls, instead of standing vertical like those of Europe, curve out gently at the base, disappearing into their moats' water with a pleasing, timeless grace. They are of large, often roughly hewn stones that stand with no mortar at all. This has given them a longevity unknown in Europe, where walls crumble with the mortar. It has also made them impervious to water pressure from inside and the earthquakes that shake Japan regularly -- the walls shift slightly under the tremors, then settle back.

Edo Castle and most others in Japan followed a basic plan similar to those of European castles. They were a series of concentric or adjacent fortified enclosures, called baileys in English and maru in Japanese, arranged to give defenders a series of protected sites to fall back to, if necessary, culminating in a central redoubt that was normally the highest and architecturally grandest point in the castle.

On your walk, you will presently come to a pair of ornate bridges that lead inside. This is the famed Nijubashi, favorite photo backdrop of all Japan. The bridges are additions of the 19th and 20th centuries, when the emperor was moved here from Kyoto after the shoguns' fall. Emperor Hirohito's palace and living quarters lie out of sight behind the walls and trees, in what was one of the outer baileys. It is closed to the public, except at New Year's and his birthday, or by special arrangements.

But pass by two more gates and you will come to Otemon, once the primary entrance to the castle. You can enter free of charge (the area is now known as the East Garden of the palace). Notice the hard right you make on entering Otemon. This is a standard design feature in the gates of Japanese castles. That way, spies could not peer inside and attackers, if they managed to breach the outer door, had to make an immediate a sharp turn, breaking their momentum and bringing them to another door, in this case much larger than the one they had just penetrated.

Before going through, pause for a look at the giant fish, a shachi, which graced the roof of a tower at Edo Castle, as at all Japanese castles, to provide luck against fire. They were often not up to the job -- a fire that leveled much of Edo city in 1657 got the main tower, too, and it was never rebuilt.

Notice, too, the gun ports in the walls. Japanese castles adapted succesfully to the age of gunpowder, unlike their counterparts in Europe. The Portuguese introduced primitive matchlock rifles here in 1543, but the cannon that in Europe began leveling castle walls never appeared in Japan in significant numbers until the 19th century.

Inside, walk through the pleasant lower gardens, then up the hill into the hon-no-maru. The moats and walls stand in all their former grandeur but alas, there is nothing left to see of the wooden palaces that once crowded the area. A clipped grassy field marks the site of the shogun's single-story residence complex, home to armies of retainers, samurai, servants and concubines. You can, however, get a peek at the back of the Fujimi Yagura, the "Mt. Fuji-viewing tower," one of the few original buildings that remains of Edo Castle. You can also see the massive stone base on which the central tower stood. Go past it and you will exit over another moat and onto a busy Tokyo street. If you're still up to walking, turn left and head up the hill. Keep turning left and you will skirt the outside of the moat -- its inner slopes today planted with carefully tended pine trees -- and eventually find yourself back at Sakuradamon.

Most Japanese cities have preserved the castle stoneworks and moats in some form. Often it is as a central park or museum of local history, usually filled with samurai armor, scroll paintings, palenquins and the like. Others have elaborately reconstructed the donjons (inner towers), generally in disguised concrete to protect against fire.

Osaka Castle, once second only to Edo's in grandeur, has a large rebuilt donjon. There is one original tower at Kumamoto Castle on Kyushu. Shimabara on Kyushu, which figured in a rebellion by Christians in the 17th century, has a rebuilt donjon and a museum inside to the revolt. Odawara's, which lies less than an hour by bullet train from Tokyo, also has a museum -- and a zoo.

Kyoto's Nijo Castle, first established in 1603 and rebuilt to its present form starting in 1624, is one of the few that is largely untouched, except for the donjon (lost to fire in 1750) and an inner palace (lost the same way in 1788). It holds to the conventions of Japanese military architecture but is miniature (only 70 acres). Serving as the shogun's residence when he visited Kyoto to confer with the emperor (Kyoto was the imperial capital), it was meant not for fighting but display of temporal powers.

Be sure to walk through the seven-building goten, or palace complex, in the outer bailey. The gate is one of the finest surviving. Inside, you can see the shogun's tatami mat audience chamber, measuring over 100 feet long, its walls covered with paintings in gold leaf of pine trees and with wall chambers which concealed bodyguards. The shogun's chambers and private offices are also to be seen. The building has famous "bush warbler floors," designed deliberately to squeak under even the lightest footstep, as warning of night-time assassins.

But anyone who wants to see the true Japanese castle must go to Himeji to see the famous White Heron Castle. It appears in the television miniseries "Shogun" and many of the films of Japanese director Akira Kurosawa. It dominates the skyline of the town even today.

The site was first fortified in 1346. Hideyoshi redeveloped it in a hurry (in the walls with the woman's millstone are scavenged pieces of stone lanterns, stone pagodas and stone coffins). Under Ieyasu, it was regarded as a key to keeping western Japan in line. That is probably why he never awarded the castle to a family to pass down through the generations, only to a succession of loyal generals whose relatives and retainers generally had to clear out on the death of the leader. The Castle of the White Heron was never attacked.

Wander first through the 650-foot, winding wooden hallway that skirts the walltops of the west bailey. In a corner turret, a famous princess named Senhime lived with her ladies-in-waiting. Samurai were billeted in other rooms along the hallways.

The castle is packed with devious architectural sleights of hand meant to confuse any attackers who got inside as to the way to the tower and to channel them along maze-like passageways that left them vulnerable to fire from the sides. A direct line from the Diamond Gate near the ticket office to the door of the tower, for instance, is 423 feet, but the shortest distance on the ground is 1,040.

Ports for guns command every conceivable approach to the castle, with ventilation holes in the halls for the smoke they gave off. Window sills have panels that can be removed to drop rocks and hot liquids down on attackers scaling the walls. (This was a very serious concern, as the slopes and rough rock of Japanese castle walls make them relatively easy to climb.) And every square inch of timber facing the outside is coated heavily with white plaster to ward off fire -- thus the castle's striking white pallor is functional as well as esthetic.

When you remove your shoes at the entrance to the main tower, take a peek in the attendant's office -- there you'll see the bulky, tool-sized keys to the original locks hanging on the wall. They are still used to lock the place up at night.

The tower stands 101 feet high above its stone base, and has three smaller towers around it. Inside, there is a well for sieges, a kitchen, a storehouse and rack after rack for weapons. The climb is steep, but you can reach the top (five stories on the outside which are somehow six on the inside) with some perserverance.

There is another legend concerning the White Heron: When the tower was finished, the wife of the master carpenter, a man named Gembei, walked through for a look. She told her husband it was a wonderful creation but too bad it slanted a bit to the southeast, as indeed the expert eye can see it does. Gembei was mortified that the fault had been spotted, and by a woman. So he climbed to the top and jumped to his death. If only the poor carpenter had known that centuries later his work would be admired as the most magnificent example of the age of Japanese castles.