What could have helped it to victory over La La Land, the favourite heading into the ceremony? Well, there are various factors that might, just might have come into play.
Firstly, of course, Moonlight is an exceptional piece of film-making. And it may well be that its coming-of-age theme, sumptuous photography and nuanced performances simply ended up resonating more strongly with voters than any of the rival films that were also nominated for best picture.
In 2016, after two years of #OscarsSoWhite, the Academy invited a large number of individuals from ethnic minority backgrounds to join and take part in voting. The Academy remains overwhelmingly white and male, although slightly less so than before.
If it was a very close race, a somewhat more diverse membership may have been a factor.
The Academy operates a preferential voting ballot. This means that one film could potentially receive the most votes as members' favourite film - which would give it victory in a first-past-the-post system of the kind employed by others, including Bafta - but still be beaten to the award by another film which had gained a significant proportion of second-favourite choices across the board.
La La Land has led the race since it premiered at the Venice Film Festival last August to rave reviews. By the time many Oscar voters saw the movie, some may have felt that after months of superlative after superlative being heaped up on it, it had been excessively hyped.
With the current political atmosphere in the United States, many Oscar voters may have thought that this was a time to honour a film that felt like a particularly important piece of work. Excellent as La La Land is, a win for the singing, dancing love letter to Los Angeles may have felt too frothy and self congratulatory.
Moonlight, a film about acceptance and struggle, certainly feels like a movie that is more than a simple piece of entertainment.