It certainly is ambiguous, the director etc intended it to be so. The original story has a slightly different ending. but the dudes here make a good point in that “it was all a dream” is a legit interpretation.
Sigggggghhhhhhhh…Okay, so they don’t look the way the majority of people think robots should look. They look the way the majority of people think aliens should look. So Spielberg made one mistake in forty years of filmmaking. Can you forgive him?
> . . . The original story has a slightly different ending . . .
The original story (“We Can Remember It for You Wholesale”) has a completely different ending. They tossed out the second half of the story and wrote a completely new one. The new one involves lots of action sequences, on the theory that audiences don’t go to any film without them: