As the U.S. Supreme Court hears arguments in today’s Proposition 8 case, a lot of people have the same question for the gay fiscal-policy writer: How would same-sex marriage affect government budgets? There’s been a surprisingly large amount of research into this question, and the answer is that same-sex marriage would probably improve governments’ fiscal situations a little.

The Congressional Budget Office looked into the question in 2004 at the request of Republican Representative Steve Chabot of Ohio. The CBO’s findings suggest that federally recognized gay marriage would reduce the budget deficit by about $450 million a year, or roughly 0.01 percent of total federal spending. So, I’m sorry, straight America: We’re not going to balance your budget by getting married, but we’ll help a little bit.

The more interesting part is how same-sex marriage affects the budget. Most people will think of it as changing income taxes and benefits for gay public employees. But some of the biggest effects come in welfare programs: Marriage makes people more robust against financial shocks and less likely to qualify for welfare programs. Same-sex marriage would save hundreds of millions of dollars a year by getting some gay men and lesbians off the Medicaid and Supplemental Security Income rolls.

On the revenue side, the CBO estimated that gay marriage in all 50 states would increase tax receipts by about $400 million a year if the George W. Bush tax cuts were extended and by about $700 million a year if they were not. Because those tax cuts ended up being mostly extended, the answer is probably somewhere in the middle, but closer to $400 million.

The added revenue comes from the “marriage penalty”: Two-earner married couples where each spouse has a similar income tend to be taxed more heavily than they would be if both partners were single. Other couples get a “marriage bonus,” generally when the spouses’ incomes are very unequal, but the marriage penalty effect is more important.

On the expense side, gay men and lesbians would get access to Social Security benefits based on spousal income. This would raise benefits for some couples, particularly those in which one spouse had much higher career earnings than the other. The CBO estimated these added benefits would cost $350 million a year by 2014.

The other main area of added expense would be benefits for the same-sex spouses of federal employees and retirees. The CBO estimated that covering same-sex spouses in the Federal Employee Health Benefits Program would cost about $80 million a year.

But there would be savings in means-tested entitlement programs, as fewer gay men and lesbians would qualify. The CBO estimated annual savings in 2014 of $100 million in Supplemental Security Income, $300 million in Medicaid and $50 million in Medicare. That makes for a wash on the expense side: $430 million in added costs and $450 million in reduced costs.

The CBO letter is an incomplete look at the federal budget. It doesn't examine the cost of benefits to the same-sex spouses of military service members, which would probably be at least as large as the cost of benefits for civilian employees. On the other hand, the letter predates the Patient Protection and Affordable Care Act, which creates another means-tested entitlement whose costs would be reduced by same-sex marriage. A more thorough analysis would probably lead to the same finding: Gay marriage has a small but positive fiscal effect.

States would also face fiscal effects from gay marriage, and their concerns are somewhat different from the federal government’s. States spend a much larger percentage of their budgets on employee compensation than the federal government does, so the cost of benefits for employees’ same-sex spouses is relatively important. On the other hand, states bear no part of the cost of Social Security and do spend a lot on means-tested entitlements.

Even though the cost components are different, the net effect would probably be similar at the state and federal levels: positive, but very small. The Williams Institute at UCLA School of Law has reached this conclusion in fiscal analyses across various states; for example, they estimated in 2009 that legal same-sex marriage in Maine would generate $8 million in annual fiscal benefits for the state, mostly through reductions in Medicaid and other public assistance payments.

The fiscal benefits aren't a crucial reason to support same-sex marriage, but they do lend support to one of the “conservative” cases for it. Marriage is a structure through which people depend on each other, so they don’t have to depend on the government. For gay men and lesbians to take advantage of that fiscally friendly option, the government has to make it legal for us to marry.

(Josh Barro is lead writer for the Ticker. Follow him on Twitter.)