LOS ANGELES (AP) – Democratic Gov. Gray Davis defeated Republican businessman Bill Simon Tuesday in a tight contest to remain in office despite widespread voter dissatisfaction over his handling of California’s energy crisis and budget deficit.

With Davis holding a 47 to 42 percent lead over Simon with 73 percent of precincts reporting, he declared victory shortly before midnight, thanking voters and campaign volunteers who helped get voters to the polls in a race that hinged on turnout.

“You are the heroes of tonight’s election and I will always be grateful to you,” he said.

The margin of victory was surprisingly close for a sitting governor in the Democrat-tilting state and reflected Californians’ overwhelming displeasure with both candidates.

Michael Stolz, a San Diego salesman, considered abstaining from voting for governor, but said he voted for Davis “kind of by default.”

In one of the most expensive non-presidential races ever, Davis raised $68 million to pay for his elaborate and unrelenting assault on Simon, the millionaire son of the former U.S. treasury secretary under presidents Ford and Nixon.

The California governor’s race became defined by the record amount spent on television advertisements – most of them negative – and by the lackluster candidates.

“I really didn’t like either one,” said Margaret Cazric of Los Angeles, who voted for Simon because of the governor’s mishandling of the power crisis. “Davis hasn’t shown he’s worth it.”

Davis spent more than $50 million on TV ads – including some $5 million in the final week. He boasted of improving schools, health care and transportation during the state’s economic boom and attacked Simon’s anti-abortion, pro-gun views.

Davis received reluctant endorsements from major newspapers and interest groups that faulted his leadership but classified him the better choice.

Simon, who had never run for public office and didn’t vote in several elections, won a come-from-behind win in the three-way March Republican primary after Davis spent more than $10 million on ads attacking former Los Angeles Mayor Richard Riordan, who was considered the biggest threat to Davis.

Simon’s campaign, hurt by a series of blunders, spent much of its time on the defense and was unable to capitalize on Davis’ problems. He failed to catch Davis’ fund raising, despite spending $10 million of his own money, and was criticized for belatedly releasing tax returns.

Simon’s family investment firm was named in an Internal Revenue Service investigation into offshore tax shelters and was also found guilty of fraud by a civil court jury, a decision later reversed by the trial judge.

Simon, 51, a former prosecutor, also mistakenly accused Davis of illegally accepting a campaign check in the Capitol while he was lieutenant governor, a charge he retracted after it was learned the photo Simon claimed was evidence was taken at a private home.

Those stumbles disappointed Republicans, including the Bush administration, who had hoped Davis’ unpopularity would help them regain the governor’s office they held for 16 years before Davis won in 1998.

After enjoying high positive ratings during the economic boom of his first two years in office, Davis’ popularity began to slip when the state suffered six days of rolling blackouts last year during an electricity crisis and then saw a budget surplus turn into a $23.6 billion deficit this year.

Davis, 59, blamed budget deficits on a national recession and said he inherited a flawed energy deregulation scheme from the previous Republican administration and accused out-of-state energy companies of gouging California.

Republicans attacked Davis’ fund-raising practices, saying he favored campaign donors while making official decisions. Davis denied those allegations.

Considered a moderate Democrat, but lacking charisma, Davis climbed through political ranks during nearly three decades in politics. He served as Democratic Gov. Jerry Brown’s chief of staff from 1975 to 1981, followed by stints in the state Assembly, as state controller and as lieutenant governor before winning his first term as governor in 1998 over Republican Attorney General Dan Lungren.

As governor, Davis boosted education spending by more than 30 percent, and student test scores have improved each year since he took office. While he received the largest percentage of campaign money from labor unions, Davis also drew support from major business interests.