The Illinois gubernatorial battle, last major remaining contest from Tuesday's election, seesawed yesterday between Gov. James R. Thompson (R) and former senator Adlai E. Stevenson III (D), with the outcome uncertain.

United Press International said Stevenson had a lead of 3,558 votes, in a News Election Service tabulation, with 185 precincts still out. The Associated Press, citing higher totals, said Thompson was 171 votes in front.

The count has been slowed by rain-soaked ballots, open, empty and missing ballot boxes, and other apparent irregularities, leading Michael Lavelle, the Chicago election chairman, to predict that the issue may have to be settled in court.

The closeness of the fight was a total surprise. Pre-election polls had shown Thompson an easy winner in his bid for a third term.

In another major governorship, in California, Los Angeles Mayor Tom Bradley (D) refused to concede the victory to state Attorney General George Deukmejian (R). Complete, unofficial returns showed Bradley losing by 52,295 votes out of more than 7 million cast.

Bradley indicated yesterday he might ask for a recount, which could cost him as much as $1.5 million. Aides were reportedly advising him to concede the election, but the mayor, who would have been the first black elected governor in American history, was said to be bitter at reports from a California pollster that 3 percent of the Deukmejian supporters said in interviews that "they could not vote for a black man."

California also had one of most unusual and hard-fought House races. Unofficial results showed Carlsbad Mayor Ron Packard, a Republican running as an Independent, had been elected on write-in ballots to succeed retiring Rep. Clair W. Burgener (R-Calif.).

Packard ran as an Independent after narrowly losing the GOP primary to Johnnie Crean, a businessman and political unknown who put $500,000 of his own money into winning the nomination and who was cited for misleading campaign advertising by a party ethics committee.

The vote count yesterday gave Packard 65,449 votes to 57,408 for political science professor Roy (Pat) Archer (D) and 55,511 for Crean. About 2,100 absentee ballots remained to be counted.

Archer said he was considering a challenge to the apparent outcome on the grounds that some early voters had crossed out his name and Crean's from the voters information booklets inside the voting booths and had written "Write-In Packard" in the booklets.

Only a handful of people have been elected to Congress on write-in campaigns. The most recent was Rep. Joseph R. Skeen (R-N.M.) two years ago.

In Fort Worth, Jim Bradshaw (R), a candidate in the newly created Texas 26th District, said he would request a recount of the election he apparently lost to former Arlington mayor Tom Vandergriff (D) by 437 votes.

Bradshaw, a former Fort Worth city councilman who in 1980 opposed House Majority Leader James C. Wright Jr., said the arrangement of the ballot in Collin County may have made his name invisible to many voters. Campaign Manager Nick Acuff pointed out that a race for the state Board of Education drew 3,700 more voters in that county than the House contest, an unusual pattern.

Vandergriff was counted among the winners in unofficial tabulations showing the Democrats had gained 26 seats in the House of Representatives, while fighting the Republicans to a no-change standoff in the Senate.

Democratic National Chairman Charles T. Manatt yesterday cited the House gains, and the net pickup of seven governorships as evidence that the "momentum is ours" for the 1984 campaign.

Democrats took over majorities in at least nine state senates or state house of representatives and, in several states, including Minnesota, Wisconsin and South Carolina, scored top-to-bottom sweeps of state offices.