What is the earliest movie in which the status of the events as reality is doubted or denied at (or toward) the end?
I will limit the case to movies in which almost all of the movie events are subjected to such doubt or denial and exclude the ones that may start "in" some character's fantasy and then fairly soon step "out" to (the movie's) reality or go "in and out" through the movie.
A famous example is The Wizard of Oz (1939), in which the events of the movie turn out to have been a dream in the end.
I have a fairly early movie in mind and will give it as an answer if others don't.
Just to incorporate some comments:
The answer could be a movie of any length, short or feature.
When "it all turns out to have been" a dream etc., it should come as a surprise to the viewer. (The viewer may then want to have a second viewing in light of what he has learned to see the changes in his own responses.)