In-In pair correlations and In surface segregation in InxGa1-xAs alloys are studied by first-principles total-energy calculations. By calculating the substitution energy of a single In atom, we find that the near-surface energetics explains the observed In segregation on InGaAs(001)-β2(2×4) surfaces. Indium surface segregation further enhances the In site selectivity, thus the long-range ordering. We find that the  and  In-In pair correlations are repulsive and nearly isotropic in bulk but are highly anisotropic near the (001) surface. The sign of the  In-In interaction energies vs the distance from the surface is oscillatory. These findings explain the recent puzzling cross-sectional ×-STM results.