SAN FRANCISCO (Reuters) - California Governor Jerry Brown on Wednesday signed a state budget passed hours earlier by lawmakers for the fiscal year beginning on July 1 that closes a $15.7 billion deficit.

The legislation, which leaves California with a reserve of more than $800 million, puts into law a budget deal reached last week by Brown and fellow Democrats who control the state legislature.

The two sides had fought over how much spending to cut from welfare programs and changes to the state's welfare system, but they managed to work out a compromise.

They also agreed to include revenue in the budget based on the assumption that voters will approve a ballot measure in November to raise the state's sales tax and increase income tax rates on the wealthy.

If voters reject that measure, California will need to cut spending on politically popular education programs by more than $5 billion, Brown has warned.

(Reporting by Jim Christie; Editing by Lisa Shumaker, John Stonestreet)