Mexico's ruling party is tightening the bolts of its electoral machine and shifting its ideological stance to the right in preparation for what could be its strongest challenge in decades in this year's mid-term elections.

Unaccustomed to serious political competition, the Institutional Revolutionary Party -- known by its initials in Spanish as the PRI -- is nervously eyeing its long ineffectual rival, the conservative National Action Party, or PAN. The victor in a recent string of key mayoral contests, the PAN is now threatening the PRI's 55-year monopoly of state and federal government.

"This is the most crucial political year in 20 years," said Bernal Sahagun, an economist and political analyst.

The PRI will face the PAN July 7, when voters nationwide select the 400 members of the lower house of Congress. In seven states, governors will be chosen. While the PRI's three-to-one control of the Chamber of Deputies appears secure, PAN's challenges at the statehouse level could force the PRI to concede its first gubernatorial losses ever, many analysts say.

The PAN's sudden strength, drawn from discontent with corruption and economic stagnation, presents President Miguel de la Madrid with a dilemma, his supporters and opponents agree. Scrupulously honest elections would burnish the president's politically valuable clean-government image. But embarrassing PRI defeats could enrage local bosses on whom the party still depends, while shattering the PRI's carefully cultivated aura of invulnerability.

Yet if fraud taints the voting, the reaction could be explosive, as illustrated late last year by riots in the Piedras Negras border town sparked by official reversals of apparent PAN municipal victories in northern Coahuila state. "In repressing the people's will, the government is opening the road to violence, as we saw recently in the north," declared PAN President Pablo Emilio Madero.

A rift between the government and private sector has catalyzed the PAN's new vigor, although powerful groups on both sides are anxious to avert confrontation. Prominent businessmen still smarting from the 1982 bank nationalization are financing local PAN campaigns, with some signing on as candidates -- a new development in Mexican politics. "A pact was broken in 1982," said historian Enrique Krauze. The rupture in the traditional government-business alliance represented "perhaps not a divorce, but a serious distancing that will be difficult to resolve."

In response, the PRI is courting the disaffected businessmen, abandoning the rhetoric of the bank takeover days when business leaders were assailed as "looters" and traitors. PRI Chairman Adolfo Lugo Verduzco, blasting PAN's business backers in a Monterrey stump speech for "illegitimately disguising themselves as corporate leaders," lavished praise on the "great majority" of businessmen who, he said, "pay taxes and fair wages and stand in solidarity with the people and government."

Jorge Trevino, the PRI's gubernatorial candidate in Nuevo Leon, joined in hailing businessmen as "a very politive force" and declared that most belong to the PRI -- a statement viewed as heretical by some within the PRI's powerful labor sector. Its spokesmen recently proposed that corporate chieftains be formally banned from party membership.

"The entrepreneurial class is a very important sector of society, and we want to continue to have a close relationship with them," said Juan Saldana Rossell, a federal congressman and head of the PRI's national Information and Propaganda Office.

While making overtures to businessmen, the government is also mobilizing its traditional labor and peasant support base, channeling public funds to politically sensitive districts, and enriching the PRI's campaign coffers with mandatory deductions from the paychecks of top bureaucrats.

The party's Mexico City leadership is also scrutinizing its state-level political apparatus, reported Saldana, acknowledging that the Coahuila disturbances made it "more aware of the need to select good candidates."

The riots, leaving one dead and a city hall destroyed, also made party leaders more conscious of the hazards of ballot tampering. In a meeting with governors, de la Madrid ordered that the July elections take place "in a peaceful climate and with strict adherence to legality."

"The president's message was a good one, but we just hope that his advice is followed," commented PAN press secretary Gonzalo Altamirano, voicing a skepticism widespread in his party's ranks.

During the first months of the de la Madrid administration, PAN candidates won an unprecedented string of solid mayoral victories in the capitals of five states north of Mexico City, successes they attributed to apparent presidential instructions to respect voting results. "It was like Switzerland up there," recalled PAN Secretary General Bernardo Batiz. "There was no interference in the voting, and the ballot count was absolutely clean."

Following those contests, PRI state captains fought back, proclaiming disputed victories in the state capitals of Puebla and Mexicali. Manuel Stephens Garcia, national election coordinator for Marxist-oriented Unified Socialist Party, which opposed the PAN in both cities, said his own tallies "indicated that the PAN won by substantial margins in Mexicali and Puebla."

"After losing those first election, the PRI hardened its line," Stephens said. "They have resorted since then to some of the most blatant electoral maneuvers seen in Mexico in 15 years or more."

Stephens and others charge registration lists were altered, poll watchers disqualified arbitrarily and ballot boxes seized at gunpoint.

Even Saldana, the PRI's chief official spokesman, recognizes that election chicanery has plagued the party. "I don't doubt that there have been frauds from time to time," he said. "Local interests are very strong, and it would be odd if there were no frauds." But statewide contests are largely free of such irregularities, and the PRI can confidently expect to win all seven governorships legitimately, Saldana contended.

Judging from past elections, the PRI should be most vulnerable in Nuevo Leon, where the PAN is historically rooted and came close to capturing the governor's office six years ago.

In Monterrey, the state capital where PAN polled 40 percent of the 1982 presidential vote, many businessmen are actively supporting PAN gubernatorial candidate Fernando Canales Clariond. But the PRI state government has reacted astutely, cultivating prominent industrialists and rebuilding the entire capital city center, proof of the PRI's ability to deliver federal funds. Local observers now rate the race a toss-up.

Many oppositionists believe PAN has a better crack at the governorship of the agribusiness-dominated northwestern state of Sonora, where PAN's Adalberto Rosas faces the PRI's Rudolfo Felix Valdez -- until last month De la Madrid's transportation minister. A career bureaucrat absent from his native state since his high school days four decades ago, Valdez is in the view of PAN strategists a perfect foil for the flamboyant Rosas, a former mayor riding a crest of provincial resentment against the overweening power of Mexico City.

"If the election were held today," said a diplomat, "there is little doubt that Rosas would win."

PRI officials argue that PAN's Sonora following is concentrated in the state capital of Hermosillo and a few smaller cities. "There is no real PAN tradition in Sonora," Saldana said, an assertion confirmed by past returns.