Thousands of people from the former Himalayan kingdom of Sikkim laid silk scarfs on the coffin of their king today and then accompanied it to a mountaintop pyre as they mourned the ruler who steadfastly refused to accept Indian annexation.

The eerie sound of eight police buglers sounding "Retreat" and "The Last Post" mingled with the music of Buddhist monks playing pipes, drums and cymbals in this borderland between China and India. And as the urn-shaped pyre that contained the coffin of the chogyal, Palden Thondup Namgyal, was set ablaze, hundreds more threw other silk scarfs onto the fire.

About 20,000 persons took part in today's nine-hour ceremonies. They were scheduled according to Buddhist astrological calculations and began at 5 a.m., when the coffin draped in the flag of Sikkim was taken from the royal monastery and prepared to be carried by hand over a four-mile steep climb to the 8,000-foot-high cremation grounds.

The chogyal was best known in the United States for his 1963 marriage to New York socialite Hope Cooke, who divorced him in 1980. She lived with him in this mountain city for more than a decade and they had two children, who live with their mother in New York.

The former ruler of this Delaware-sized mountain kingdom, now India's 22nd state, died Jan. 29 at the age of 59 at the Sloan-Kettering Memorial Cancer Institute in New York. He was cremated in an oblong coffin specially made to accommodate his body in the lotus position of meditation that he reportedly had been in at the time of his death.

The outpouring of emotion at the ceremony today followed more than two weeks of mourning. The late ruler, whose family has controlled Sikkim since 1642, called India's 1975 annexation of his country illegal and unconstitutional.

There is little chance, however, that India will ever give up Sikkim, which it regards as strategically vital since it is astride the 14,000-foot natural pass into Chinese-occupied Tibet. Foreigners are seldom even allowed to visit the area. Indian and Chinese troops last clashed at the pass, which is just 32 miles from here, in 1967.

"That pass is the curse of Sikkim. Things would be a lot different if it was not there," said one person close to the royal family.

In their simple way, many of the mourners at today's ceremony seemed to accept their former king's view of Indian rule.

"There is no difference, still we associate with the chogyal," said Agya Tshering, 72, of India's takeover of Sikkim. His voice was choked with emotion and tears ran down his weathered face as the old farmer bowed before the chogyal's coffin and added a silk scarf--a sign of respect--to the large pile already there. He said he had traveled 90 miles from his western Sikkim village of Dentan to pay his respects.

The chogyal's oldest surviving son, Price Wangchuk, 29, said this view has become more apparent since his father's death. As an example, he said, civil servants who formerly avoided him on the streets came to the palace to pay their respects and help arrange the ceremonies.

"The outpouring of sentiment," the prince said in an interview Thursday in his father's cozy, book-lined library, "is a pretty obvious vindication of my father's stand and a direct denial of the popular Indian view that the king was an autocrat whom the people wanted to get rid of."

A senior civil servant here agreed. "In their heart of hearts and mind of minds, the people have all their sincerity, devotion and loyalty to the late chogyal. This could be seen at the funeral," he said.

Nonetheless, the death of the former king marks the end of a tragic decade for him. In his final years, he lost his country and his wife and then his oldest son was killed in an automobile accident.

Tonight, after the cremation ceremony, groups of Sikkimese village leaders converged upon the palace to lay scarfs at the feet of Prince Wangchuk and urge him to take the position of the new chogyal.

"As a mark of his recognition he was placed on a throne in the palace," said Capt. Christopher Roland, who for 14 years had been aide de camp to the late chogyal. The captain said the people want the prince to be chogyal for Sikkim's culture, religion, continuation of its history "and to lead the people in the future."

But he did not say that the prince would become the political leader of Sikkim.

Later, the prince said, "I accept that title of chogyal."

When India took control in 1975 after two years of unrest that many here now say was manipulated from New Delhi, the chogyal was placed under house arrest in his hilltop 15-room palace. His small band of guards was overpowered easily by India's central reserve police and its 25,000 soldiers stationed to protect the kingdom.

But despite alternating pressure and offers of comfortable jobs, he refused to sign the articles of annexation. Palace sources said they still sit on his desk here.

The Indian government, which had stripped the chogyal of his title and declared him a commoner, insisted that he be called Mr. P.T. Namgyal. But today's edition of the state government newspaper, the Sikkim Herald, in a front-page story called him the "late chogyal."

The parade of people placing silk scarfs around the coffin today included the family, who came as dawn broke over the snow-capped peaks in the distance. The family was followed by government officials and commoners, some of whom were barefoot despite the cold weather. The coffin was flanked by the old palace guards who had been overcome by the Indian police seven years ago.

"I am paying my last respects to our former king," said Kishor Das, 48, a Hindu whose family has lived here after coming from neighboring Nepal three generations ago.

The procession began forming shortly after 9 a.m., when the Buddhist monks dressed in maroon or brown robes, some wearing hoods, carried colorful banners signifying victory over evil. Playing their instruments and chanting, the monks led the procession three times around the royal monastery. Members of the chogyal's family and some of his close associates--including a minister in the present state government--hoisted the coffin, which was fastened to two poles, to their shoulders and joined the circling of the monastery.

The procession included a white pony for the king's liberated soul to ride away from his body.

The procession stretched for miles up the mountain as teams from different sections of Sikkim took turns carrying the coffin. After more than three hours it reached the royal cremation grounds.

The rites cost more than $200,000, with the government of India--which holds about $125 million of the chogyal's funds pending a final settlement--expected to foot the bill. The costs included: $49,000 to feed the monks; $27,000 to pay them for 49 days of prayers; $27,000 for snacks for palace visitors, and $25,000 to feed those attending today's rites.