It took 15 years of international political wrangling, but Clemente Diego Baltazar this week finally shed his label as Guatemalan war refugee and became a legal resident of Mexico, the country that has grudgingly allowed him to farm and raise a family here for most of his adult life.

In a gesture that closes a rancorous chapter in the history of Central America's guerrilla conflicts, Mexico this week began granting formal legal status to the last of about 22,000 refugees who remained here after Guatemala's 36-year civil war formally ended with a peace treaty three years ago.

"I came here to Mexico 15 years ago," said Diego Baltazar, 40, clutching a folder of naturalization papers. "I had four children here; they are all Mexicans. I'm happy here. This is my home now."

At the same time, the Guatemalan government has begun repatriating the final few hundred refugees seeking a return to their homeland, and the U.N. refugee agency has formally ended all aid to the communities of Guatemalan refugees that had spread across Mexico's southernmost states nearest the Guatemalan border.

"This is the time for a warm hug for those who return from an exile that never should have happened, and a time for hope and good wishes for those who decide to stay [in Mexico]," Guatemalan President Alvaro Arzu said in a joint ceremony with Mexican President Ernesto Zedillo on Wednesday, sweltering under a tent filled with hundreds of Guatemalans who reside in this refugee community of 3,238 in the Yucatan peninsula state of Campeche.

Zedillo described the final naturalization and repatriation of the refugees as the "happy culmination . . . of the good understanding that exists" between the two countries. But relations between them on the refugee issue had been anything but warm or understanding over much of the last two decades.

During the height of the Guatemalan government's crackdown on suspected rebel sympathizers in the 1980s--in which tens of thousands of civilians were executed and hundreds of villages were destroyed--an estimated 45,000 war refugees, most of them indigenous Mayans, fled into neighboring Mexico. Most settled in makeshift camps in Chiapas, Mexico's poorest and most politically unstable state.

In 1984, Guatemalan troops invaded some of the camps in Mexico, alleging they were harboring rebel sympathizers. Mexico used the incursion to relocate large numbers of refugees to the neighboring states of Campeche and Quintana Roo, citing the refugees' safety. But many believed Mexico relocated the camps out of fear that the refugees would add to the growing political unrest among indigenous populations in Chiapas.

Mexican authorities attempted to maintain tight control over the relocated refugees by denying them the right to leave the state or claim titles to land they farmed.

Since the Guatemalan peace treaty, an estimated 40,000 refugees and their families have returned to their native country. But another 22,000--half of them children born after their parents escaped to Mexico--decided to remain in the refugee camps, which had developed into full-fledged towns, however poor, where most houses are built of slender tree trunks with roofs of tar paper or corrugated tin.