John Rankin scored the decisive goal in a topsy-turvy match at Tannadice to give Dundee United a 3-2 victory over Kilmarnock.