All hail to Kirsten Dunst for giving two of cinema's outstanding performances this year, one tragic, one comic – and for the same film.

The tragic one you'll see this week – in Lars von Trier's Melancholia, Dunst plays a woman whose wedding is unfortunately scheduled just as the Earth is due to collide with another planet. It's a remarkable performance – mercurial, intense, troubling – and it won Dunst the Best Actress award in Cannes this year. But she also deserves the prize for Best Straight Woman in a Farce, for Melancholia's Cannes press conference, at which the Danish director confessed to understanding Hitler and joked about being a Nazi.

In fact, these assertions were part of a stream-of-consciousness ramble in which Von Trier also teased Dunst with a running gag about his next film. She and Melancholia co-star Charlotte Gainsbourg, he claimed, had badgered him into casting them in a four-hour porn movie, telling him: "We just want a lot of unpleasant sex.'" Dunst smiled gamely throughout, but when the Nazi remarks began, she chewed her lips in pained disbelief. Playing foil to a misfiring stand-up can't be fun, but Dunst got in a mesmerising display of double takes, to the joy of thousands of YouTube users.

Hollywood names often shy away from controversy, but Dunst seems to enjoy the clouded response that Melancholia itself received in Cannes – it echoed her reception there with Sofia Coppola's deliberately anachronistic Marie Antoinette, which largely mystified critics in 2006. The day after the Melancholia premiere in Cannes, I asked her whether she enjoyed hostile responses.

"Yes, it's a good sign. It's better than 'That was good', and then move on to the next. Even if you don't like this movie, it's gonna mess with you somehow, or make you really angry. What I've noticed in myself is when I've got really angry with films, there's sometimes something in me that I didn't want to see, that I was feeling but didn't even know it yet."

Dunst's embracing of Melancholia's cosmic angst confirms that she has cast off her long-standing image as a rosy-cheeked ingénue. For a long time she was a professional girl-next-door – literally next door, in the case of Mary Jane in the Spider-Man films, a figure she managed to suggest was as existentially neurotic as her arachnoid squeeze.

Born in New Jersey to a German father and Swedish-American mother, Dunst, 29, was spotted as a toddler and quickly launched as a child model and actor – she did her first commercial aged three, then made her first film appearance at seven in Woody Allen's section of the portmanteau New York Stories. She played plucky suburbanites in kids' adventures Jumanji and Small Soldiers, went on to build a repertoire of college girls and cheerleaders – and occasionally overplayed the joie de vivre, as in the excruciating romcom Elizabethtown. But she also turned in striking, considerably darker performances – a disturbed LA rich girl in Crazy/Beautiful, a bitterly unsympathetic reactionary student in 1950s drama Mona Lisa Smile. She also impressed mightily in Peter Bogdanovich's 1920s showbiz drama The Cat's Meow – a role that allowed her to peel back the skin of her own "modern flapper" image.

Dunst's pithier roles are given an edge by her appearance, her bonny all-American bloom: she once described herself as looking "Aryan, like a Swedish milkmaid." Her looks were memorably used against the grain by Sofia Coppola, who cast her first in The Virgin Suicides, dismantling the myth of the Californian golden girl; then in Marie Antoinette, where Dunst's bemused Austrian princess is the ultimate poor little rich kid, a baffled outsider crushed by Versailles protocol and the pressures of royal stardom.

It's not that surprising that Dunst has chosen a film as sombre as Melancholia, given that she made her first real splash at 12 as a prepubescent fiend, in Neil Jordan's Interview with the Vampire. Her character, Claudia, had chubby cheeks, Shirley Temple ringlets and a lust for blood – Dunst's precocious knowingness making the part all the creepier, and pathetically touching. Understandably, she then went for something less threatening – Little Women. "I was a young girl and that's what I would relate to – I wasn't this, like, morbid child."

Off screen, Dunst has been a constant media presence, sometimes literally a media object – Japanese artist Takashi Murakami transformed her into a blue-haired manga heroine for Tate Modern's 2009 Pop Art show. She's also been a gossip column favourite, dating Tobey Maguire, Jake Gyllenhaal and British rocker Johnny Borrell, with whom she lived in Islington (reportedly infuriating neighbours with loud post-pub parties).

For a long time, Dunst was one of Hollywood's less scandalous presences, until her reputation as a self-confessed "out-on-the-town girl" caught up with her. In 2008, she checked into a treatment centre in Utah, insisting it was for depression. The actress has been open, but discreet, about the topic. Not so Lars von Trier, who cheerfully raised it at his press conference, explaining why Dunst was perfect for his film: "I would say that Kirsten has, thank God, some knowledge of depression." Then, turning to her, he added: "I am really happy that you are mentally disturbed."

In fact, Dunst explains, she and Von Trier were happy to use their common acquaintance with the black dog. "Lars opened up to me about his personal depression .... That also makes you feel more open with him."

As with other female Von-Trier stars – Catherine Deneuve, Nicole Kidman, Gainsbourg – Dunst's relationship with the director seems to be at once thorny and oddly protective.

"My first impression was how vulnerable and how sensitive he is – I felt, even though I didn't know him, 'I'll take care of you!'", she laughs. "That's his vibe.... But he can be very shocking."

Asked which directors she wants to work with, Dunst gives a less than predictable reply – Tarantino you'd expect, but she's also keen on Michael Haneke, and German-Turkish director Fatih Akin. Among her upcoming films, the most tantalising prospect is Brazilian director Walter Salles's adaptation of Kerouac's On the Road, where she plays the fictional incarnation of Beat writer Carolyn Cassady.

Meanwhile, Melancholia has raised Dunst's profile, marking her as a natural choice for dramas about psychic torment – and for comedies of social embarrassment. Of Von Trier's Nazi gaffe, she says, "I was very embarrassed .... You can't joke about something like that." Did Von Trier apologise to his actors? "Yeah," Dunst says, then lets out a ripple of laughter. "In his way."

But would she ever work with the Dane again? "Yes, but not in the four-hour porno." She laughs again. "And you know, if he really does it, I'll be so offended!"