For four centuries, master carpenters from the Nishioka family have worked on the splendid wooden pagoda and halls of the Horyuji temple complex. It is a good bet that the man now in the job, Tsunekazu Nishioka, is the most satisfied and confident the family has ever produced.

Under his exacting supervision, the major structures of Horyuji, founded in the year 607 and often called Japan's finest surviving work of ancient wooden architecture, have been dismantled beam by beam, tile by tile, then restored and put back together.

At age 4, Nishioka began learning the craft's manual skills and oral traditions. But he says it was only decades later, as he pondered pieces laid bare for the first time in centuries, that he began to grasp the spiritual ties between tools and timber.

"The old builders were people of art who approached their work with religious devotion . . . . They had no way to know how their creation would fare over the span of 13 centuries," he said. "The privilege of finding out fell to me. I felt like a highest-level doctor of anatomy." He predicted that Horyuji is good for another 20 centuries.

His project began in 1934 and was no rush job. Official completion ceremonies for what is known at the temple as the Great Showa Repair -- Showa is the name of the reign of Emperor Hirohito -- took place only in November, 51 years later. Now 77, Nishioka is looking for new challenges.

Horoyuji contains 55 significant structures and holds a special place in Japanese history. It stands at the base of a wooded hillside near Nara, imperial capital for 84 years during the 8th century. It is a setting rife with ancient artifacts and associations, part of the regional plain the Japanese call Yamato, cradle of their race and civilization.

Within the limits of Horyuji's tiny town of Ikaruga are 50 ancient burial mounds. Earlier this year, one was opened and yielded an elaborate ceremonial saddle. The identity of the body in its stone coffin, which will be opened next year, is not known. "We can only say that he was a powerful person of high station in this area," said Hiromi Kurimoto of the town's education committee.

Horyuji was founded by the great philosopher prince of Japanese antiquity, Shotoku, importer of Chinese learning and Buddhism. The buildings drew architectural inspiration from Chinese models. It became one of the "Great Seven Temples of Nara" and a center for propagation of the new faith.

Around the year 700, it was swept by fire and destroyed almost in total. But the artisans soon rebuilt it, and significant parts of what the visitor sees today is their work. The five-tiered, spired pagoda, one of Japan's most wonderful sights, is said to have 90 percent of its original wood. The Kondo main hall is ranked as the world's oldest wooden building.

Hard times had fallen on Horyuji by the early 20th century, however. Buildings were marred by broken tiles, rotting wood and weeds. Visiting foreigners urged priests and government to act. An American doctor and patron of the arts, Harvard graduate William Sturgis Bigelow, gave a donation that priests today call the seed money for the entire reconstruction program.

When the Showa repairs finally got under way in 1934, financing came from the central government, which was trying to preserve "national treasures," the temple and a national "backup" group that tapped businesses and private donors.

Work was interrupted during World War II, as whole sections of the temple were dismantled and taken into the hillsides to be safe from American firebombing. The precautions were unnecessary, in fact, as the United States had exempted Nara and nearby Kyoto from raids to preserve the cultural sites there.

Over the centuries, the buildings had been patched and altered countless times. "Our guiding principle in our work was to return to the old design, to wipe away all additions and changes," said Ryoshin Takada, a priest who is secretary general of the temple.

Determining precisely what was the old style, however, was no easy task. Workers drew on paintings, some of which had remarkable detail, and on old wood that their predecessors had removed but reused in some other form. Living quarters and other structures not in the original plan were demolished to restore the old ambiance, curves on roofs were rounded, walls that had been removed were replaced.

As time passed, Nishioka said, it became clear that the old builders had gathered all their hinoki, a type of white cedar native to Japan and a wooden temple's prime material, from the Yamato area. That was as it should be.

"In our craft, we have a set of unwritten principles," he explained in his home, located just outside the temple's walls. "One is, 'don't buy trees, buy a mountainside.' " A temple's wood should come from a single site. Wood should be positioned in the orientation at which it grew as trees, with beams from the mountain's north side on the north, and so on.

Each tree, shaped by its soil and decades of wind and rain, has a unique personality, artisans say. The builder, then, must understand and exploit these traits. Trees twisting slightly to the right should be used in conjunction with those twisting left, so that in the end the sum of the forces is zero.

"Coming from a family of craftsmen, I had learned these principles already," Nishioka said. "But it was only when I took the buildings to pieces that I discovered that all of Horyuji was constructed in this way. I was extremely moved. The oral tradition had been applied without exception."

Later artisans, however, forgot them, he says, as evidenced by work done six centuries ago. "They simply matched good-looking trees with good-looking trees," he complained. "But when I rebuilt, I reverted to the old ways, perceiving the nature of individual trees, matching them north and south."

Nishioka maintains that none of the new tools or materials available today improve on the old ones. He stressed the use of the traditional ax and spear plane, a curved blade attached to a long wood handle, in his work. He insisted that his roof tiles be baked at low temperatures for long periods, rather than for a short times at high temperatures, the method commonly used today.

Still, with the government paying for much of the work, corners had to be cut. "With a saw we can make a cut in five minutes," he said. "With a spear plane, it takes two hours." Power tools were used for rough work, although he maintains the cut is inferior, and hand tools for refinement.

Another departure from ancient practice was installation of fire control systems. Wherever possible, pipes and nozzles were hidden but Nishioka said it was still not aesthetic. "If everyone who came here had true religious feelings, these things would not be necessary," he fumed. Most visitors these days are tourists.

Perhaps the most painful compromise was with wood. The government required that he take his hinoki from national forests. He did his best, he said, but the oldest hinoki to be found in Japan these days is only 450 years old. The ideal age is 1,500.

In 1971, Nishioka began work on a new temple at Yakushiji, a few miles from Horyuji. With private money funding it, he demanded the right to do everything the traditional way. That was granted and he flew to Taiwan and bought a mountainside of old hinoki.

Recognized today as the foremost practitioner of the art in a country now built mostly of concrete, he is constantly sought out for help by temples. He attributes much of his knowledge to his long repairs at Horyuji. "Everything is clear now. I have full confidence," he said.

Last month, after spending the equivalent of $40 million over the years, the temple officially declared the restoration complete with two days of ceremonies. Horyuji will now turn its attention to repairing lesser buildings and cataloguing about 100,000 items and documents piled in storerooms.