He found a discrepancy in Ampere's law and fixed it. With the fixed equations, he found that the now-called Maxwell's equations had free-space solutions in the form of waves.
He found that the wave solutions travel at the speed of light, so he guessed that they were light.