It's a 5-4 decision, Justice Kennedy writing for the majority. Initial reports are that the ruling is predicated on marriage being fundamental right (which the high court has held many times going back to the 19th century) and the Equal Protection Clause.