MEXICO CITY — A Guatemalan judge on Monday ordered Efraín Rios Montt, the former dictator, and his intelligence chief to stand trial on charges of genocide and crimes against humanity in connection with the massacres of villagers in remote highlands three decades ago.

The ruling clears the way for a public trial for Mr. Rios Montt, a former general who ruled Guatemala for 17 months in 1982 and 1983 during the bloodiest period of the country’s long-running civil war. It is a stunning decision for Guatemala, where the military still wields significant power behind the scenes and the country’s elected governments have struggled to build democratic institutions.

“The principle function of the state and its officials is to protect its citizens,” said Judge Miguel Angel Gálvez before finding that there was sufficient evidence to try Mr. Rios Montt, 86, and another former general, José Mauricio Rodríguez Sánchez.

The two are accused because they had final command over troops that killed 1,771 people in the Mayan-Ixil region as soldiers carried out a scorched-earth campaign to hunt down left-wing guerrillas.