Gov. Mark White survived a scare in the Democratic primary tonight, emerging with barely enough votes to avoid a runoff against an obscure challenger. His victory set up a rematch with former governor William Clements, who won handily over Rep. Tom Loeffler and former congressman Kent R. Hance in the Republican primary.

With 82 percent of the Democratic votes counted, White held 54 percent to 22 percent for Andrew Briscoe III. In the Republican primary, Clements was drawing 58 percent with about 82 percent of the ballots counted. To avoid runoffs, they had to obtain at least 50 percent of the votes.

White suffered from a strong protest vote by state teachers, upset with mandatory competence tests, and public employes, who complained that he had not followed through on promises for pay raises.

He also was hurt by the recession that has hit Texas since oil prices fell. The state's unemployment rate has reached 8.5 percent, the highest in decades, and the budget deficit exceeds $1.3 billion.

Clements, the first Republican governor of Texas in a century but defeated by White in 1982, ran a surprisingly strong race from beginning to end against two tough opponents, exuding a sense of calm and composure that often eluded him in his last race.

In interviews tonight, Clements said he lost last time because his polls made him overconfident. He said that avoiding a runoff saves his campaign $500,000, "which we can use where it will do the most good -- getting rid of Mark White."

Much of the campaign money will come from Clements' own pocket. He is a Dallas multimillionaire.

For Hance, this was the second loss of a major primary race in two years, one in each party. In 1984 Hance lost in a runoff for the Democratic senatorial nomination against Lloyd Doggett. He then switched parties to make this race for governor. Hance conceded at 11 p.m. after waiting several hours for West Texas results that he had hoped would pull him into a runoff.

Hance, a graduate of Texas Tech, said the results reminded him of a football game in which Texas beat Texas Tech 49 to 7. "Afterwards they tell the coach: 'You shoulda passed.' Heck, we could have passed more, run more, and it still wouldn't have changed the results. We just got beat."

Hance said he felt the voters wanted another chance to support Clements after the economic hardships they have suffered in recent years. He said he would campaign for Clements.

The loss for Loeffler was the first of his political career. Although deputy minority whip in the House, he appeared to suffer from a lack of name recognition outside his Hill Country district.

George Strake, Texas Republican Party chairman, said he was surprised by the results. "I just didn't think Clements could win without a runoff with the other two guys working as hard as they did," Strake said. "Apparently he came out as a person who could best solve the problems of the state."

White, who trails Clements in head-to-head polls by as much as 12 percent, said he considered his renomination tonight a solid victory, even though he faced five obscure opponents who campaigned with little money or publicity.

The second-place finisher, Briscoe, is a distant cousin of former governor Dolph Briscoe Jr., who gave White his start in politics by appointing him secretary of state.

The magnitude of the Anybody-But-White vote became clear in the margins of victory for his running mates. Lt. Gov. William Hobby and Jim Hightower, agriculture commissioner, both received more than 75 percent of the primary vote.

White nonetheless appeared optimistic when he made a victory speech late tonight. He noted that he received twice as many votes as Clements. He did not say, however, that there were three times voters in the Democratic primary.

"This vote demonstrates that the people of Texas want better schools. They want better roads," White said. "All the other campaigns have been based on negativism. We're basing ours on hope and optimism. Texans never accept anything but the very best. And we've just begun."

An analysis of the vote showed White receiving less than 50 percent in East Texas, West Texas and the Panhandle -- areas where teachers mounted strong protest campaigns because of their opposition to mandatory competence tests. He ran strongly in South Texas, where the Hispanic vote is largest.

On the Republican side, Clements was dominating the vote in Houston and Dallas, where about two-thirds of the estimated 400,000 Republican votes were cast.

In another contest of national interest, Roy R. Barrera was winning the Republican primary for attorney general, although he appeared to be heading for a runoff. Barrera would be the first Hispanic candidate for one of the state's top offices.

The primaries come as the state is suffering a severe economic recession caused by the decline in oil and gas prices. There is strong disagreement among political experts whether this will eventually help the Democrats, who usually fare better during hard times, or the Republicans, who in this case have White as a target.

White began the day in Houston, where he voted at Lanier Junior High. He later traveled to San Antonio, the center of the state's Hispanic vote, where he campaigned with that city's popular mayor, Henry Cisneros.

Clements spent the day in Dallas, where he voted, worked a telephone bank for an hour, and appeared anxious to get the primary and general elections out of the way and return to office.

Loeffler voted in his Hill Country district and then rode to San Antonio to watch the results.

Hance campaigned frenetically in the final week, making 35 stops in four days.

The three Republican candidates spent about $9 million during the campaign, and each borrowed heavily for final television blitzes. Clements recently borrowed $775,000 from a Dallas bank, Loeffler borrowed $319,000, much of it from San Antonio auto dealer Tom Benson, and Hance borrowed $200,000.