If I understand correctly, they are using the "equal protection" clause, because the courts ruling let stand the marriages that had already taken place. Supposedly the courts couldn't undo them because of "ex-post facto" considerations. However, there is precedent for this type of law.
Various laws have been passed with "grandfathering' clauses written into them. Laws ranging from zoning regulations to gun laws that restrict ownership of various types of "machine guns", have had grandfather clauses.