We report on the results of a systematic ab initio study of the magnetic structure of Fe rich fcc FeNi binary alloys for Ni concentrations up to 50 at. %. Calculations are carried out within density-functional theory using two complementary techniques, one based on the exact muffin-tin orbital theory within the coherent potential approximation and another one based on the projector augmented-wave method. We observe that the evolution of the magnetic structure of the alloy with increasing Ni concentration is determined by a competition between a large number of magnetic states, collinear as well as noncollinear, all close in energy. We emphasize a series of transitions between these magnetic structures, in particular we have investigated a competition between disordered local moment configurations, spin spiral states, the double layer antiferromagnetic state, and the ferromagnetic phase, as well as the ferrimagnetic phase with a single spin flipped with respect to all others. We show that the latter should be particularly important for the understanding of the magnetic structure of the Invar alloys.