We demonstrate the experimental implementation of an optical lattice that allows for the generation of large homogeneous and tunable artificial magnetic fields with ultracold atoms. Using laser-assisted tunneling in a tilted optical potential, we engineer spatially dependent complex tunneling amplitudes. Thereby, atoms hopping in the lattice accumulate a phase shift equivalent to the Aharonov-Bohm phase of charged particles in a magnetic field. We determine the local distribution of fluxes through the observation of cyclotron orbits of the atoms on lattice plaquettes, showing that the system is described by the Hofstadter model. Furthermore, we show that for two atomic spin states with opposite magnetic moments, our system naturally realizes the time-reversal-symmetric Hamiltonian underlying the quantum spin Hall effect; i.e., two different spin components experience opposite directions of the magnetic field.