California's finances are golden again.

After multi-billion dollar shortfalls in recent years, the state's budget has finally straightened out. California expects to take in $2.4 billion more in revenue than it will spend this fiscal year, which ends June 30. After paying off a shortfall from last year and setting aside funds for upcoming obligations, it's on track to end the year with a $36 million surplus.

If the legislature approves Governor Jerry Brown's 2013-14 budget proposal, California should have enough money next year to increase funding for education and pay down debt, while setting aside $1 billion in a reserve fund.

"For the next four years, we're talking about a balanced budget. We're talking about living within our means," Brown said last month when he unveiled his budget. "This is new. This is a breakthrough."

What prompted the turnaround?

Three things: Major spending cuts over the last few years, big tax increases approved by voters in November and general improvement in the economy.

When Brown took office in 2011, the state faced a $26.6 billion budget gap. To close it, the state slashed spending for schools, the correctional system, health and human services and higher education.

California's general fund spending dropped to $93 billion this fiscal year, down from a peak of $103 billion in 2007-08. The state workforce contracted by more than 30,000 positions. Spending on schools plummeted to $47.3 billion last year, down from $56.6 billion four years earlier. The state limited the time adults could receive welfare cash assistance to as little as 24 months, down from 60 months.

The new budget for next year increases spending in certain areas, particularly education. The general fund is projected to grow by 5%, to $97.7 billion.

"It's been a long time since California has had a budget that didn't consider significant cuts in health, social services and other programs," said Jason Sisney, director of state finance for the Legislative Analyst's Office. "We have a relative degree of stability for the first time in half a decade."

Another major contributor is the state's new revenue stream.

California is on track to take in $95.4 billion this year, including nearly $6 billion from the passage of major, temporary tax increases in November. Millionaires will pay a top rate of 13.3% through 2018, while the state's sales tax rate will be a quarter point higher through 2016. Corporations will also pay higher levies.

Meanwhile, California's finances are improving as the general economy gains ground. The state has been creating jobs faster than the nation for a year -- its unemployment rate is now around 9.8%, down from 12.4% in October 2010 -- and its housing market is rebounding more swiftly, according to Gabriel Petek, analyst with Standard & Poor's. The rating agency rewarded the state by upgrading its credit rating last week. (It is now the second lowest-rated state, behind Illinois.)

Don't break out the bubbly just yet, though. California's new balancing act is as fragile as a Jenga tower.

The state is still highly dependent on income tax revenue from the wealthy, a notoriously fickle source. The tax increases prompted grumblings from wealthy residents like golf star Phil Mickelson, and spurred other states, such as Texas, to encourage businesses to move.

Related: Texas to California businesses: Move here!

"Millionaires don't make a million dollars every year," said Mike Genest, a consultant and former state finance director under Republican Governor Arnold Schwarzenegger. "The idea that we have emerged from our historic budget shortfalls in a sustainable way is very questionable."

All of the state's budget figures and forecasts for the year are still guesswork. California will have a better idea of exactly how much revenue it will collect this year -- and whether it will still have a surplus -- when it issues its revised forecast in May.

Another risk is that lawmakers will want to restore many of the services and funding that were slashed during the Great Recession and its brutal aftermath. Brown has pledged continued fiscal constraint, but that can be difficult to accomplish politically.

If legislators don't approve certain measures in Brown's budget proposal, such as the continuation of some fees and taxes, the state could dip back into the red at the end of its 2013-14 fiscal year. It would run a tiny $7 million deficit, according to projections from Brown's finance office.

And like many states, California has yet to deal with its longer-term problems. The big whammies there include unfunded liabilities associated with the teachers' retirement system and state retiree health benefits.

California officials will also have to keep a close eye on decisions emanating from Washington, D.C. Federal spending cuts could slow California's economy.

"There are still risks out there that are out of the state's control," said H.D. Palmer, a spokesman for the state Department of Finance.

Federal policy makers are now facing many of the same issues -- spending cuts, tax increases, safety net reforms -- that plagued California for years. Perhaps they can take a lesson about making those tough choices -- and the payoff you get when you do.