TOKYO — Japanese Emperor Akihito gave thanks Friday to the gods for a bountiful autumn harvest, the last time he will perform one of most important annual palace rites before abdicating next spring.

Akihito conducted the Niiname ritual on Friday at an Imperial Palace shrine illuminated by torchlight as ancient music was played. He offered harvested rice and other items to the gods, thanking them and praying for peace for the nation. Nov. 23 is Japan's national thanksgiving holiday.

Some of the rice was harvested by Akihito from a field inside the palace grounds. The rest was offered by farmers from around the country. Ahead of the ritual, Akihito invited some farmers to ask about their harvests this year, according to Japanese media.

Akihito is to abdicate on April 30 and will be succeeded the following day by his son, Crown Prince Naruhito.

Naruhito observed his father perform the ritual on Friday.

The religious harvest prayer is one of about 20 rituals that the emperor performs privately at the palace each year, separate from his official duties.

The two-part ritual runs past midnight — including a three-hour interval — inside the unheated shrine, making it difficult for the 84-year-old emperor. He has attended only the first half of the rite in recent years, with an aide performing the latter half.

According to tradition, the emperor must sit straight with his legs tucked under him for nearly two hours while performing the ancient ritual. He reportedly stays awake at his palace to make sure the ritual ends safely.

In order to prepare, Akihito sits in the posture while watching television or during meetings, according to the Mainichi newspaper.