When Lee Miller arrived in Paris in 1944, the newly liberated city was just embarking on a three-day bender.

"Paris had gone mad," she later wrote. "The long, graceful, dignified avenues were crowded with flags and filled with screaming, cheering pretty people. Girls, bicycles, kisses and wine, and around the corner sniping, a bursting grenade and a burning tank. The bullet holes in the windows were like jewels, the barbed wire in the boulevards a new decoration."

Dressed in her army fatigues, the model and muse-turned-war photographer moved through the city seeking out the friends she knew before the war: Jean Cocteau, the poet Paul Eluard and, of course, Pablo Picasso. "This is the first allied solider I have seen and it's you!" he exclaimed with pleasure when she turned up at his studio in the Rue des Grands Augustins.

There's a picture of that meeting. Picasso, squat and bullish, has his hand around the neck of the willowy, tall Miller in an embrace. The clear affection in the eyes of both is clear to see. It's a photograph that sums up a friendship, one that would last more than 30 years and one that is now at the heart of a new exhibition, Lee Miller And Picasso, which opens today at the Scottish National Portrait Gallery in Edinburgh.

"What an incredible image that is," Miller's son Antony Penrose tells me when I bring it up. "She knew exactly where to find him. She had fought across northern Europe with the US 83rd Division. After the siege of Saint-Malo she recognised the liberation of Paris was imminent and she just bummed a ride and she was there on the first day of liberation."

Picasso had survived in the city under Nazi occupation but many of his friends had not. "So the sense of relief must have been huge," Penrose says. "And the person that should arrive with the news that Paris was liberated was Lee Miller."

Miller's story would make a great movie. It nearly did a few years ago when David Hare wrote a script and Nicole Kidman was keen to star, only for everything to fall apart when she split from her then husband Tom Cruise whose company owned the film rights. More's the pity because Miller's story has a cinematic sweep to it.

At 19 she was pulled from in front of a car by magazine magnate Conde Nast who, struck by her looks, put her on the cover of Vogue. Soon she became one of America's top models but, bored, she left for Paris and fell in with the surrealists, eventually becoming Man Ray's lover and muse.

She started taking photographs herself. During the war she brought her surrealist's eye to London during the Blitz. (In fact, take another look at that description of Paris after liberation and note that image of bullet holes in glass "like jewels". Tell me that's not the surrealist in her speaking.)

She then followed the invasion of Europe all the way to the concentration camps. Her resulting black and white images of Dachau sing with anger and bleakness.

After the war Miller married the English surrealist painter Roland Penrose and settled - if that's the right word for a woman haunted by what she had seen and drinking heavily as a result - in Sussex. And as a result, Tony Penrose grew up playing with Picasso on the artist's many visits.

"We didn't speak a word of each other's language," Penrose recalls. "But we didn't need to because he had the same attitude towards children as he had towards animals. He just liked us. If he'd ever failed as an artist he would have been a great children's entertainer."

Over time Penrose started dressing like Picasso. He even stood up to eat ice cream with his back to the wall because that's how he had witnessed Picasso stand in cafes.

There was the odd scrape. Penrose did bite Picasso once. "We started off this game of bull fights. I was the bull and I would thunder across the room and try to knock him over and he would sidestep and I would go splat into the wall. I got fed up with this so I thought of a different strategy. And that is when I bit him. He let out a yelp and then bit me right back. And before I started to yelp, Mum heard him say 'Tiens! That's the first Englishman I've ever bitten.' There may have been others but I was the first."

These days Penrose is in charge of his parents' archives. He has spent his life researching theirs, unravelling their twisting lives in all their complexity through all the years of love and conflict. During the Second World War Roland Penrose and Miller were involved in a menage a trois with Life Magazine's David Sherman, the man who would take the infamous photograph of Miller washing herself in Hitler's bathtub in Munich in 1945. Later, Roland's first wife would move in with him and Miller in Sussex. In short Penrose's parents were properly, proudly bohemian in their outlooks.

Miller's friendship with Picasso began in the 1930s and stretched until just a couple of years before his death in 1973. The last images in the exhibition date from the end of the 1960s. It's possible they met in the early 1930s via Man Ray, but there's no evidence. But in June 1937 Roland Penrose met Miller in a surrealist fancy dress ball in Paris when he was, in his own words, "struck by lightning". Such was the impact of meeting Miller. They were inseparable after that and later that summer he drove her across Europe to the south of France for what became a "sort of surrealist summer camp" with Man Ray, Eluard and Picasso. "Picasso was immediately rather smitten by Lee Miller," her son suggests, "by her incredible beauty but also her fieriness, her wit and her strength as a personality."

Given their respective love lives, the temptation is to ask if they were lovers at some point. "Oh, I'm sure they were," Penrose says. "I don't have evidence. Well, would I? But I think when you look at the series of pictures that he made of her, they're very sexy pictures."

Not that everyone could see that. In later years people would tease Miller mercilessly about Picasso's vision of her, according to her son. "'What happened? You look really scary.' And she would laugh and say, 'But if you look closely it's got my smile.' When you look at the paintings you'll realise that he's got her gap-toothed grin. If you look at photographs of Lee, you'll very rarely see her photographed with her mouth open because she was very conscious of the gap. So he gave her this great big toothy grin and the big lips, the beautiful, sensuous lips which she was so well celebrated for."

Of course today it's not just her looks she is remembered for. Her photographs, a thrilling melange of the deft, the humorous and the dark, full of craft and art, are her legacy. And as Penrose points out, "whatever area she chose to be in - fashion photographer, combat photographer - she was head to head with men who enjoyed the privilege of their gender, and it meant that Miller and other women of her time had to be a very lot better than the men to hold their own."

When we speak Penrose is preparing to go to Vienna where another exhibition of Miller's work is being mounted, a retrospective that includes a special section of her work from the city in 1945. "This is really tough stuff. There are photographs of children dying in hospital because black market people had stolen all the medicines. The Third Man was a true story. And Lee photographed the results of it. And for me that is the moment when things in her deepest level turned. The war was supposed to be the war that delivered the brave new world. But it didn't. It just delivered the same bunch of crooks doing the same stupid things. It wasn't surprising she had a tough time after that. She went into alcohol abuse and depression."

This troubled soul was the mother Penrose knew growing up. A difficult woman. Her past life was unknown to him for many years. Her relationship with Picasso, as the Scottish National Portrait Gallery exhibition will hopefully prove, is a different way to frame her story. One smelling of fresh paint and developing fluids, dappled with Mediterranean light and warmed by friendship. Here are their days in the sun.

Lee Miller And Picasso opens at the National Portrait Gallery today and continues until September 6. Tickets cost £9 (£7 concessions), www.nationalgalleries.org