Quantum and classical physics can be used for mathematical computations that are hard to tackle by conventional electronics. Very recently, optical Ising machines have been demonstrated for computing the minima of spin Hamiltonians, paving the way to new ultra-fast hardware for machine learning. However, the proposed systems are either tricky to scale or involve a limited number of spins. We design and experimentally demonstrate a large-scale optical Ising machine based on a simple setup with a spatial light modulator. By encoding the spin variables in a binary phase modulation of the field, we show that light propagation can be tailored to minimize an Ising Hamiltonian with spin couplings set by input amplitude modulation and a feedback scheme. We realize configurations with thousands of spins that settle in the ground state in a low-temperature ferromagnetic-like phase with all-to-all and tunable pairwise interactions. Our results open the route to classical and quantum photonic Ising machines that exploit light spatial degrees of freedom for parallel processing of a vast number of spins with programmable couplings.