BANGKOK  Myanmar will hold its first elections in two decades on Nov. 7, the ruling junta announced Friday, setting a date for a vote that has been denounced by opponents as a means of legitimizing military power within the format of civilian rule.

The former main opposition party, the National League for Democracy, is boycotting the elections, saying the electoral rules are unfair and restrictive. Its leader, Daw Aung San Suu Kyi, a Nobel Peace laureate who has spent most of the past 20 years under house arrest, is legally barred from running in the election because she is under government detention.

The party was officially disbanded in May because it refused to register for the campaign. It will be on the sidelines during the elections, and it remained unclear what role it might play in the future as a nonparty organization.

The brief election announcement, carried on government radio and television stations in Myanmar, formerly Burma, said, “Multiparty general elections for the country’s Parliament will be held Sunday, Nov. 7.” It gave political parties until the end of this month to submit their candidate lists.