A popular young border-city mayor is giving Mexico's ruling party its toughest challenge ever in a gubernatorial race that could set the tone of Mexican politics for years to come, politicians and independent analysts say.

"I'm confident I can win," Francisco Barrio said during an interview in his sparsely furnished campaign headquarters here. Mexico's corruption scandals and economic collapse "have created a strong current of antigovernment sentiment in Chihuahua," he said. "All we have to do is channel it."

Contending that opinion polls show him with a solid majority in the July 6 election for governor of Chihuahua State, Barrio has threatened to organize massive civil disobedience if the government tries to cheat him of victory.

Professionals in the government's Institutional Revolutionary Party (PRI) take Barrio seriously, saying he is giving them the stiffest competition they have ever faced in a gubernatorial race. Last year the PRI withstood several gubernatorial challenges from Barrio's National Action Party (PAN). Government strategists said that while local officials fraudulently padded victory margins they never genuinely feared defeat.

As mayor of Ciudad Juarez, the largest city in Chihuahua State and the biggest municipality ever controlled by Mexico's opposition, Barrio commands political and economic resources rare in an antigovernment candidate. Elected mayor with substantial business support, he has since broadened his base among the city's working-class majority, local political analysts say. And in the countryside, the government party's traditional stronghold, peasants are said to be responding enthusiastically to the 34-year-old Barrio's agressive, old-fashioned stump rhetoric.

"The PRI sees Barrio as a dangerous candidate," Jose Luis Munoz, a PRI state committee spokesman, said. "He is young, good-looking and a good talker. He has a very marketable image."

"Barrio is a very capable politician, and I have no doubt he could win," agreed a PRI central committee official dispatched to monitor the Chihuahua campaign. "A PAN victory might even be good for the country, for the government's image. But the odds still favor the PRI."

Some officials privately agreed with critics who charge that the government will not concede defeat in Chihuahua or any other northern border state, regardless of the election results.

"It's a matter of sovereignty," said one, alluding to what government loyalists see as an unpatriotic pro-U.S. slant in the National Action Party's conservative economic and foreign policies. "Maybe we could let them win some little state in the interior, but never on the border."

Other officials said they would welcome an opposition victory as proof to domestic and foreign critics that Mexico's democracy is "authentic." But if the Chihuahua vote is marred by widespread irregularities, it will be taken as evidence of further consolidation of the "authoritarian, antidemocratic currents" in Mexico's present government, historian Enrique Krauze said.

A third the size of neighboring Texas, Chihuahua is the biggest and among the wealthiest of Mexico's 31 states. Chihuahua's people are still outnumbered by cattle, and cowboy boots and broad-brimmed hats remain the working man's uniform. But the great ranching and timber fortunes that once dominated state politics are being eclipsed by new industrial empires manufacturing goods for export, businesses that have been an important source of funds and talent for the PAN.

The PRI should still be able to win the July 6 election cleanly, many independent analysts believe, by running a close race in Chihuahua cities and amassing a heavy rural vote.

The government candidate, Fernando Baeza, is a respected federal congressman with long experience and powerful backers in state politics. He has at his disposal an impressively experienced and well-financed political machine that has adopted such expensive tactics as the distribution to voters of cut-rate fuel oil.

But the government's past electoral abuses will make many Chihuahuans question even a legitimate PRI victory this year, officials privately conceded. Moreover, as the 1985 elections demonstrated, the federal government may be incapable of stopping fraud on the local level.

"Local bosses steal votes whether the PRI needs them or not, because they want people to be indebted to them," a ranking member of Mexico's last administration said. "It is almost impossible to control."