Terrence Malick's mad and magnificent film descends slowly, like some sort of prototypical spaceship: it's a cosmic-interior epic of vainglorious proportions, a rebuke to realism, a disavowal of irony and comedy, a meditation on memory, and a gasp of horror and awe at the mysterious inevitability of loving, and losing those we love.

Sean Penn has a central but minor role as Jack, a careworn 21st-century corporate executive who is now disenchanted with his life. At the moment of crisis, he is carried back to an ecstatically remembered 1950s boyhood in smalltown America. He remembers his relationship with his demanding, disciplinarian father, played by Brad Pitt, and the brother who died at the age of 19: the news is brought to his distraught mother (Jessica Chastain) via an official communication – the telegraph delivery boy thrusts it into her hands and walks quickly away – so he appears to have died on military service.

Jack realises that time, far from healing the wounds of loss, only makes them more painful. Along with the dream-lit tableaux from his childhood, he is vouchsafed extraordinary visions of geological time and the unknowable reaches of the universe, in comparison with which his loss is meaningless. And yet meaning has to be found if the pain is not to be unendurable. In a sense, the purpose of these gigantic visions is to anaesthetise the pain of being alive and not understanding.

Brad Pitt dominates the bulk of the film as Mr O'Brien, who appears on the face of it to be a God-fearing family man with a button-down shirt and crewcut, brusquely but sincerely in harmony with his gentle, beautiful and profoundly religious wife. Chastain has a voiceover at the very beginning asking her sons to prefer God's grace to the beauties of nature, as the truer path. But O'Brien is far more complex than first appears: he is angry with his boys; he respects the severity of traditional churchgoing belief, but aspires to riches and worldliness, taking out patents in the aeronautics industry and dissipating the family's means in the process.

He challenges his boys to hit him, to toughen them up, and does not hesitate to hit them for disobedience and discourtesy. He plays the organ in church and is a disappointed musician; his frustration and rage simmer from every pore. His boys feel fear as well as love: Malick shows how they have fused into the same emotion. They are encouraged to respect his violence and secretly to feel contempt for their mother's gentleness, and yet their fascinated alienation expresses itself in one startling scene involving an incursion into the parental bedroom.

And there are the baffling and bizarre symphonic passages of non-narrative spectacle, prehistoric jungles, arid deserts, galaxies and spiral shapes – Kubrickian landscapes of wonder. Weirdest of all is the engorged river in which a wounded dinosaur lies prostrate; another dinosaur comes along, plants its great foot on the other's neck and then moves heedlessly on. Is this the only message of the universe – pure survival? But then how is it we want something other than survival? What do we want to survive for? And Malick appears, through sheer crazy excess, to bring his movie closer to the ultimate question: why does anything exist at all?

This film is not for everyone, and I will admit I am agnostic about the final sequence, which suggests a closure and a redemption nothing else in the film has prepared us for. But this is visionary cinema on an unashamedly huge scale: cinema that's thinking big. Malick makes an awful lot of other film-makers look timid and negligible by comparison.