The mistake was discovered when the La La Land producers were in the middle of their acceptance speeches. Watch the video below :
PriceWaterhouseCooper, the accountancy firm responsible for counting the ballots, apologised for the mix-up.
La La Land still ended up the biggest winner of the night, taking home six Oscars including a best actress award for Emma Stone.
Moonlight's surprise best picture win took its haul to three, the low-budget film having earlier won the adapted screenplay award and a best supporting actor prize for Mahershala Ali.
Casey Affleck was named best actor for Manchester by the Sea, while Viola Davis was named best supporting actress for Fences.
Damien Chazelle, La La Land's 32-year-old director, became the youngest film-maker to win the best director Oscar.