King Bhumibol Adulyadej sat on a throne on a balcony overlooking a plaza packed with a crowd that police estimated at 200,000 as he delivered a brief homily on national harmony.
Most in the crowd were dressed in the royal color of yellow, many waving Thai flags and flags adorned with the king's insignia.
Respectfully silent during the monarch's halting words, they shouted "Long live the king" afterward, as well as when he made his way to and from the ceremonial Ananta Samakhom Throne Hall.
The turnout was a vivid demonstration of the affection in which many hold the king, despite political turmoil in recent years that has raised doubts about the future of the monarchy.
The king's infrequent public appearances are poignant, since he is very visibly infirm with age and uses a wheelchair. He has spent the last three years living in a hospital, where he sometimes carries out royal duties such as the swearing-in of high officials.
The king, who took the throne in 1946, was originally hospitalized in September 2009 with a lung inflammation. Official statements have said he remained at the hospital for physical therapy and nourishment to regain his strength.
Bhumibol's family flanked him Wednesday for part of his appearance, including Crown Prince Vajiralongkorn, his son and heir-apparent. However, his wife, Queen Sirikit, 80, was absent from the ceremony.
The royal palace issued a statement saying the queen's doctors advised her against attending as even standing by the king's side for an extended period might be strenuous for her because she is weak. She suffered stroke-like symptoms in July.
Several spectators in the packed crowd fainted in the high heat and humidity and needed medical attention.
The king's occasional speeches in recent years have stressed the need for unity.
On Wednesday, he thanked people for coming, saying their apparent show of unity "delighted and encouraged" him.
"If Thai citizens still hold this virtue (harmony) in their hearts, there is hope that in whatever the situation, Thailand would surely get through it safely and stably," he said.
He called on Buddha and holy spirits to bless the country and its people.
The king traditionally has played a conciliatory role in Thai society, and his decline in health has coincided with trouble in the Southeast Asian nation.
A 2006 military coup ousting then-Prime Minister Thaksin Shinawatra ushered in a period of political instability marked by sometimes violent street protests. Supporters of Thaksin blamed the palace—though not so much the king himself—for supporting the coup.
The resulting social polarization brought into question the monarchy's role in politics, undermining what had previously been near-universal respect for the royal institution.
The king's near-disappearance from the public scene has also raised concerns about what will happen after his passing. Crown Prince Vajiralongkorn does not command the same respect and affection as the king, who was closely and actively involved in his country's development efforts.
Thaksin's sister Yingluck Shinawatra, Thailand's current prime minister, led senior officials from government, the military and the courts in swearing allegiance to the king Wednesday. Her brother, who is in self-imposed exile avoiding prison on a corruption conviction, remains the No. 1 enemy of Thai royalists, who accuse Thaksin of trying to usurp the king's powers and denigrating the monarchy.
Open discussion of the monarchy and its future is difficult, because a lese majeste law makes it easy to prosecute people who have been accused of insulting the king or royal family. If convicted, they can be sentenced to three to 15 years in jail. There have been dozens of such cases in recent years, with several people convicted and jailed.