A divided Supreme Court sided with gun control groups and the Obama administration Monday, ruling that the federal ban on “straw” purchases of guns can be enforced even if the ultimate buyer is legally allowed to own a gun.

The justices ruled 5-4 that the law applied to a Virginia man who bought a gun with the intention of transferring it to a relative in Pennsylvania who was not prohibited from owning firearms.