Only weeks before the broadest and most open election in 18 years of authoritarian rule, Brazil's military government is struggling to control the slow and meticulously planned movement toward democracy it launched three years ago.

While safeguarding its ultimate power with a series of intricate electoral laws, the Army administration of Joao Figueiredo has scheduled voting in November for Congress, state governors, state legislatures and municipal officials. It is allowing four opposition parties to challenge government candidates freely.

The result, to the dismay of some military leaders, has been an explosion of political activity in Brazil's major cities. Thousands of candidates from the right to the socialist left have plunged into a free-for-all of fund-raising dances and beach parties, urban wallposter wars and nearly nightly rallies and television debates that have all but neutralized a binge of government campaign spending.

Despite the splintering of the government opposition into four electoral fronts, opposition candidates are now expected to win control of the National Congress as well as the governments of most of the populous southern states that drive the country's rapidly industrializing economy.

As a result, the approaching elections are widely expected to be both a crucial test and a turning point for political liberalization in Latin America's largest and most powerful country. Although Figueiredo has promised his government will accept an electoral loss rather than give up its plan for democracy, most politicians expect the Brazilian military to base its future plans on a judgment of the election results--and there is concern over a right-wing backlash to a resounding government defeat.

"A portion of the Army believes in democracy, but it also believes in control," said Alexandre de Barros, a Brazilian political scientist who specializes in the military. "Each move is tested and observed and then taken with the attitude, 'Let's see how it goes,' before any new liberalization is planned."

For opposition leaders, the elections offer an opportunity to gain political power that, while clearly inferior to that of the government, will allow party leaders to pressure the military for further advances and negotiate key national policies.

"We will have veto power in a way that will force a process of bargaining," said Raphael de Alimeida Maglhaes, a leading Rio-based candidate of the opposition.

If that process proves successful, politicians and foreign diplomats say, Brazil's slow and controlled style of military "decompression" could have a key influence on other military-ruled South American states. There, abrupt withdrawals by military rulers have frequently led only to unstable civilian governments and repeated coups.

In fact, leaders of the government's Social Democratic Party favorably contrast Brazil's measured social and political change with both the revolutions of Central America and the volatile shifts between military dictatorship and populism in neighboring Argentina, which is now beginning a full but precipitous transition to democracy.

The Social Democratic Party, which has no connection to the international social democratic movement, represents the military and civilian groups that have supported the military during its rule.

"What is important to us in Brazil is the demystification of revolution as an implement of social change," said Celio Borja, a liberal Social Democratic federal legislator now running for the Senate. "Our attitude is to reestablish a political tradition in Brazil of peaceful change through an expanding democratic system."

That there is a need for such change is widely accepted even by Brazil's conservative military rulers, who overturned a left-of-center government in 1964 and implanted a strict, technocratic administration that has overseen the vast expansion both of Brazil's economic power and its deep-rooted social inequalities.

Although Brazil is now the undisputed economic leader of Latin America, even opposition leaders concede their campaigns will not reach broad sectors of the country's lower classes, particularly the 25 percent of the adult population that is illiterate and thus banned from voting.

So far, the government's liberal political and social programs have been directed principally at the urban middle and working classes and their traditional political movements. Since taking office in 1979, Figueiredo, a retired general, has loosened controls on the press, freed political prisoners and sponsored an amnesty of both exiles and military leaders who participated in repression of the 1960s.

Along the way, Figueiredo, a stocky, bespectacled and low-keyed president, has gained a significant measure of popularity that the government party has made the focus of its electoral strategy.

Though not a candidate, Figueiredo himself has begun tirelessly stumping the country's rural states -- where the Social Democratic Party is strongest -- and contrasting his concrete achievements against what he says are the unachievable promises of the opposition.

"This is the prime material of my democratic faith," he declared at one recent rally, pounding his chest with his fist as tears filled his eyes.

This barnstorming has been complemented by a massive patronage and pork barrel campaign that has ranged from the doubling or tripling of public works budgets in economically pressed areas to the free return by the government savings bank of 380,000 wedding rings pawned by poverty-stricken owners in recent years.

The military's ultimate security, meanwhile, has been guaranteed by an intricate series of laws for "electoral reform" that during the past several years were tailored to increase elected representation from areas where the government is strong, to provide ways of circumventing any opposition majority in the National Congress and to ensure that the electoral college that chooses Figueiredo's successor as president in 1984 will be government-controlled. The electoral college will be made up of some elected officials, none of whom face an election at the time it is formed. While the details on the formation of the electoral college have not yet been decided, observers expect the government to ensure itself a majority.

Nevertheless, the Party of the Brazilian Democratic Movement (PMDB), a coalition of government opponents ranging from the moderate right to the left, has, like other opposition parties, raised millions of dollars for its major campaigns and assembled an apparatus that is often as strong as the government's. The Democratic Movement and the government party receive the support of most of the business community.

The Democratic Movement is now leading the government in the key state of Sao Paulo and other areas.

In Rio de Janeiro, Democratic Movement gubernatorial candidate Miro Teixeira has been buying television time at the rate of $3,500 a day, helping to prompt a recent move by the local government to ban paid political advertising in the final weeks before the election.

Most of the campaigning, however, has been based on relatively simple appeals: rallies, dances, well known names, and slogans that are plastered all over big city slums and trailed from airplanes over Rio's crowded beaches. "PMDB -- For an End to Misery," promised one typical banner in the ramshackle Rio ghetto of Rocinha.

Both the opposition and the government campaigns have led to complaints that the election has grown empty of real issues or programs. The politicians respond that their campaigns reflect the nature of an election that has more to do with symbolism than with real power.

"You have to remember that this is not yet a democracy," said Rangel Bandeira. "What we are fighting over is the democratic process itself."