The California Public Employees' Retirement System (CalPERS) opposed bankruptcy protection for the city over concern the city would cut public-pension money from its debts.
CalPERS lawyers had argued the city did not budget wisely and ignored warnings of impending financial crisis.
San Bernardino filed for bankruptcy protection in 2012 with a $46 million deficit. The city said only essential services could be paid for, and that required city contributions to CalPERS would not be met.
Federal Bankruptcy Judge Meredith Jury granted the bankruptcy protection.
The Associated Press contributed to this report.