Spin models are the prime example of simplified many-body Hamiltonians used to model complex, strongly correlated real-world materials1. However, despite the simplified character of such models, their dynamics often cannot be simulated exactly on classical computers when the number of particles exceeds a few tens. For this reason, quantum simulation2of spin Hamiltonians using the tools of atomic and molecular physics has become a very active field over the past years, using ultracold atoms3or molecules4in optical lattices, or trapped ions5. All of these approaches have their own strengths and limitations. Here we report an alternative platform for the study of spin systems, using individual atoms trapped in tunable two-dimensional arrays of optical microtraps with arbitrary geometries, where filling fractions range from 60 to 100 per cent. When excited to high-energy Rydberg D states, the atoms undergo strong interactions whose anisotropic character opens the way to simulating exotic matter6. We illustrate the versatility of our system by studying the dynamics of a quantum Ising-like spin-1/2 system in a transverse field with up to 30 spins, for a variety of geometries in one and two dimensions, and for a wide range of interaction strengths. For geometries where the anisotropy is expected to have small effects on the dynamics, we find excellent agreement withab initiosimulations of the spin-1/2 system, while for strongly anisotropic situations the multilevel structure of the D states has a measurable influence7,8. Our findings establish arrays of single Rydberg atoms as a versatile platform for the study of quantum magnetism.