Justine has just married Michael and they are traveling to the country for their reception which is taking place at the sprawling estate owned by Justine's sister, Claire. Claire's husband, John, is in a bad mood because he never wanted to host the celebration of their marriage at his home and he certainly never wanted to pay for it. Justine and Claire have a dysfunctional family and a large part of its dysfunction is Justine, who suffers from melancholia and feels numb inside. The "happy" couple are two hours late for the reception because they are traveling in a stretch limousine that has difficulty negotiating the tight turns and the winding, narrow rural roads.
Justine works as a copywriter and has made the error of asking her boss to give a speech at the reception; an error, because he is not a particularly nice man, and an error because he uses the speech as an opportunity to put more professional pressure on Justine; he reminds her that she has a copywriting deadline to meet, and later in the celebration hounds her about writing a tagline for a project before she leaves for her honeymoon. He also deploys his nephew Tim to trail Justine all evening in the hopes that he will be able to get a tagline out of her as his uncle demands. He is diligent when it comes to trailing her, and the two end up in a sand trap on the estate's private golf course, where they have sex, but Justine still doesn't produce the tagline for him and for this transgression Tim is immediately fired by his uncle. Justine quits too, but not before she tells her boss what a nasty, ruthless, and vindictive little man he really is.
The strange thing about the reception is that Justine and Michael haven't spoken; a few hours into proceedings and they come together to talk, and learning that Justine has already had sex with another man, Michael suggests that they dissolve the marriage, a suggestion to which Justine readily agrees. The following morning, Michael leaves early, whilst Justine goes on a horseback ride with Claire. She is concerned that she cannot see the constellation of stars that is usually visible and later the women discover that this is because a rogue planet, Melancholia, has sneaked into the solar system from behind the sun, and is hurtling towards earth.
Claire is frightened, and researches more about Melancholia on the internet when she discovers articles that state the planet is headed straight for Earth and that the collision will bring about the destruction of Earth and the end of time. John, however, is skeptical and tells her that real scientists know that the planet will pass by Earth, and that those saying otherwise are scaremongering and looking to make a name for themselves on television.
For a time, it seems that the real scientists John mentioned might be right. The planet passes by Earth; nothing collides, nothing happens, Earth is safe. Everyone is relieved, but Claire is still discomforted and filled with a sense of foreboding. She takes an instrument that her young son, Leo, has made; it is circular and it is designed to look more closely at the planets. She realizes that Melancholia is actually getting much bigger and that it is going to circle back, hitting Earth. She runs to the stables to tell John about her discovery but finds him dead, having committed suicide by taking all of the pills that Claire was saving for herself and her family.
She heads back to the house and summons her family for breakfast, keeping up a normalcy that is convincing. However, Justine notices John's absence and asks Claire where he is. Claire is saved from answering her question by the first crack of a giant hailstorm caused by Melancholia's close proximity to Earth. Claire snatches up her little boy, Leo, and runs to the car, but none of the cars will start, and the golf cart shorts out just before she gets to the bridge where Justine's horse had refused to cross the day before. She runs back to the house. Leo, her son, is terrified, and is crying for his father, but Justine tells him that they will be safe because she is going to make him a magic cave. Justine, Claire and Leo go out onto the golf course, where they sit down and await their fate. Claire is crying softly; Leo has his eyes closed but is no longer scared; he is sure that the magic cave surrounds them and that they will all be fine. Justine is stoic; she's not scared, and is fatalistic about what is going to happen.
Melancholia collides with Earth and the planet turns into a wall of flame. The world ends.