WASHINGTON—The Supreme Court dramatically advanced gay rights Wednesday in rulings that direct the federal government to provide equal treatment to same-sex spouses and allow the resumption of gay marriages in California.

In a pair of 5-4 rulings on the final day of the court's term, the justices struck down the 1996 Defense of Marriage Act, which denied federal benefits to gay couples married under state law, and let stand a ruling...