Marvel brought him in and shared some of the early concepts they had for the film. He came back to them with a multi-page proposal within a week (maybe even the next day) and got the job based on that.
And yes, Feige still has more say-so, Whedon is just overseeing the Avengers, though he does give input on the scripts and coordination of the other movies in the MCU. For example, Thanos was cast jointly by Whedon and Gunn.