In the past five years, more than 5 million museum visitors have queued – and queued some more – for a brief glimpse of the work of Yayoi Kusama. The 89-year-old Japanese artist, who for the past 41 years has lived voluntarily in a psychiatric hospital, has had large-scale solo shows of her work in Mexico City, Rio, Seoul, Taiwan and Chile, as well as major touring exhibitions in the US and Europe. Last year, she opened her own five-storey gallery in Tokyo. The Broad museum in Los Angeles recently sold 90,000 $25 tickets in an afternoon to its Kusama exhibition, causing the LA Times to ask if the artist was now “Hotter than Hamilton?”

As the numbers have gone up, so the time that each visitor can spend in Kusama’s installations – her immersive “infinity mirror rooms” of coloured lights, and painted pumpkins and polka dots that reflect for ever – has gone down. In 2013 the David Zwirner gallery in New York was restricting time slots to 45 seconds for each viewer. Five years on, visitors to the Hirshhorn Museum in Washington DC, who queued for more than two hours, were down to a brisk half a minute.

How did this happen? The most obvious single word answer is “Instagram”. People – hundreds of thousands of them (see #YayoiKusama or #InfiniteKusama) – photograph themselves in Kusama’s unique spacey wonderlands and share the results. Many modern art galleries are currently exploring the idea of exhibition as uploadable social media “experience”. Kusama – in developing an idea she first presented in New York in 1966 – has already cornered the market.

This autumn sees more new work on display at the Victoria Miro gallery in London – only two years since its last open-all-hours event. The exhibition coincides with the UK release of a film about the artist’s extraordinary life, Kusama: Infinity. The story of the making of the film is indicative of the ways Kusama’s fortunes have soared. Its director, Heather Lenz, first tried to get the idea off the ground in 2001. She pitched the story to every production company she could think of and was told the same thing by all of them. Her idea was “too arty”, Kusama had “no name recognition”, and “no one wants to watch a movie about a woman artist”. No longer.

Kusama boldly made the decision to leave Japan and go to New York while that was a pretty shocking thing to do. Heather Lenz, director

Speaking on the phone last week, Lenz acknowledged that the smartphone-friendly nature of the work is clearly part of the attraction – but said that should only lead to a deeper understanding of Kusama’s career.

“Most people have seen her work on Instagram,” Lenz says, “but when they hear what she had to go through to achieve the success that eluded her for so long, they really connect with that. We did a few screenings and though most people knew the work, out of an entire audience only two people knew for example that she lived in a psychiatric hospital.”

Lenz’s film reveals how Kusama’s life has been if anything more estranging than her obsessive work, and the ways in which one informs the other. It does it no harm as a tale of perseverance and triumph that it falls into neat chapters of Kusama’s self-transformation.

In the first of these, Kusama’s childhood, the curious seeds of the art world’s favourite selfie-craze were sown. Kusama was born into a wealthy family in rural Japan that managed extensive plant nurseries, growing varieties of violets and peonies and zinnias to sell all over the country. From a very young age Kusama would carry her sketchbook down to the seed-harvesting grounds and sit among the flowers until, as in a fairytale – of the Grimm kind – one day she experienced the flowers crowding in and talking to her. “I had thought that only humans could speak, so I was surprised the violets were using words. I was so terrified my legs began shaking.” This was the first of a series of disturbing hallucinations – she calls them depersonalisations – that haunted her childhood.

Those episodes seem to have been connected to the dislocations of her home life. Kusama grew up in a deeply unhappy family. Her father was a philanderer and her mother sent Kusama to spy on him with his mistresses, though when she reported back, she recalls in her autobiography, “my mother would vent all her rage on me”.

Her mother tried to stop Kusama from painting – tearing the canvas from her hands and destroying it – insisting that she studied etiquette in order to make a good arranged marriage. Kusama kept on drawing. It was her way of making sense of her hallucinations: flowers from the tablecloth that enveloped her and chased her upstairs; sudden bursts of radiance in the sky. “Whenever things like this happened I would hurry back home and draw what I had seen in my sketchbook… recording them helped to ease the shock and fear of the episodes,” she recalls.

Many of the motifs that have become her trademarks were, apparently, rooted in this practice. The first pumpkin Kusama saw was with her grandfather. When she went to pick it, it began speaking to her. It was the size of a man’s head. She painted the pumpkin and won a prize for it, her first, aged 11. Eighty years on, her largest silver pumpkin sculptures sell for $500,000.

After the attack on Pearl Harbor, when Kusama was 13, she was conscripted to work in a factory that produced fabrics for parachutes. In the evening, she painted intricate flowers over and over. The local paper, in a notice of her first exhibition, reported her producing 70 watercolours a day.

Seeing stills of Kusama’s early life in Lenz’s documentary – her hair cut straight across her forehead, photographed among flowers – makes a stark and moving contrast to footage of the artist at work in her studio now. The same slightly bulbous eyes peer out from under a red wig as she joins up her dots with a magic marker, chewing her lip like a child. “To me,” Lenz says, “Kusama’s childhood trauma was instrumental in her work not just because of her difficult family, but also because of her society and the nightmare of the second world war.”

Lenz came to understand these pressures more keenly because while making the film she herself married into a Japanese family and learned the history of her husband’s grandfather, killed by the bomb at Hiroshima, and her mother- and father-in-law who had an arranged marriage. “That gave me a greater understanding of her childhood,” she says. “The expectations of the time for a young lady, an arranged marriage, kids. Kusama boldly made the decision to leave Japan and go to New York while that was a pretty shocking thing to do.”

That second chapter of Kusama’s journey began when she first encountered the work of Georgia O’Keeffe in a bookshop in Matsumoto, her home town. She found O’Keeffe’s address in New Mexico and wrote to her for advice about how she could make her way in the New York art world, sending some of her own intricate watercolours of surreal vegetal forms and exploding seed pods. O’Keeffe replied, puzzled at first why anyone, let alone a young woman in rural Japan, might want to do such a thing, but the curiosity developed over several years to a kind of mentorship. “In this country an artist has a hard time making a living,” O’Keeffe replied. “You will just have to find your way as best you can.”

Yayoi Kusama at an artistic “happening” in New York’s Central Park in 1969. Photograph: New York Daily News Archive/Getty Images

Kusama arrived in New York in 1958, aged 27, with a few hundred dollars sewn into the lining of her dresses, along with 60 silk kimonos and some drawings. Her plan was to survive by selling one or the other.

In her own account, she subsisted initially on scraps of food including fish heads scavenged from the fishmonger’s rubbish, which she boiled for soup. She trailed her work around the city. “One day,” she recalls in her autobiography, “I carried a canvas taller than myself 40 blocks through the streets of Manhattan to submit it for consideration at the Whitney Annual. My painting was not selected and I had to carry it 40 blocks back again. The wind was blowing hard that day and more than once it seemed as if the canvas would sail up into the air, taking me with it. When I got home I was so exhausted I slept like the dead for two days.”

Her breakthrough works, the Infinity Net paintings, emerged from an earlier series of watercolours entitled Pacific Ocean, which she had made in response to watching the tracery of waves on the surface of the sea when she had flown for the first time from Tokyo. The nets she painted were made from a repetitive singular gesture of impasto in little loops, like interlocking scales; the longest canvases measured 30ft. One of these canvases sold in 2014 for $7.1m, a record for a living female artist. The first ones she sold to fellow artists Frank Stella and Donald Judd in 1962 for $75.

For a while, Judd and Kusama lived in the same building on 19th Street in Manhattan. “She would sit around my apartment and talk, or I’d go down there and we’d talk,” Judd recalled in an interview in 1988. “She’d work right through the night, as far as I could tell. Most paintings were done in one shot. I don’t understand how she could do that, but she would start in a corner and then go across.”

One of the startling things about watching Lenz’s film is the way that Kusama seemed to be written out of pop art history. There was a point in the 60s when she shared almost equal billing – and notoriety – with the likes of Andy Warhol and Claes Oldenburg. Part of this eclipse seems to have been by design – Kusama has long claimed that her original ideas were appropriated by the Wasp-ish men around her and passed off as their own.

In 1963 she started making chairs and other objects covered, fungi-like, with white painted phallic forms made of stuffed fabric; her pièce de résistance was a rowing boat, complete with oars, that she and Judd rescued from a junkyard. It was presented in a box-like space, the walls, ceiling and floor of which were papered with 999 silk-screen images of the phallic boat. She saw it as her own private aversion therapy.

A waxwork figure of Yayoi Kusama at Madame Tussauds, Hong Kong. Photograph: VCG/Getty Images

“I began making penises in order to heal my feelings of disgust toward sex,” she later wrote. “My fear was of the hide-in-the-closet-trembling variety. I was taught sex was dirty, shameful, something to be hidden. Complicating things even more was all the talk about ‘good families’ and ‘arranged marriage’ and the absolute opposition to romantic love… Also, I happened to witness the sex act when I was a toddler and the fear that entered through my eye had ballooned inside me.”

There is a grim irony in this act of therapy in that her technique of “soft sculpture” appears to have been adopted by Oldenburg, and her repetitive wallpaper prints by Warhol. She despaired at the way the men around her found fame with her ideas.

Lenz’s film seeks to expose that appropriation. “Every single Q&A I do I get a question about how much the allegations that these white male artists stole her ideas were true,” Lenz says. “Obviously I checked all the dates and they all work out as she said. People who had degrees in art history still challenged this though; it was as if they don’t want to shift their views. They know what they know, I guess.”

Kusama found something like her ideal man in Joseph Cornell, the reclusive genius of the outsider art world, maker of surreal boxes of found objects, and a man who, then in his 50s, had always lived with his mother. Cornell became obsessed with Kusama, sending her a dozen poems a day, never hanging up from a phone call so he was there when she picked it up to dial. This was her only known romantic relationship, though “he didn’t like sex, and I didn’t like sex so we didn’t have sex”. He wasn’t an easy man. One time she was at Cornell’s house and they were sitting on the lawn. Cornell’s mother appeared, struggling up the garden with a large bucket of water. She tipped the contents over them, at which Cornell clung to his mother’s skirt and pleaded with her: “Mother! I’m sorry! Forgive me, but this person is my lover, please do not do such outrageous things.”

After that episode Kusama cooled somewhat. She began her first experiments with mirrored infinity, in an octagonal room filled with stuffed phalluses, and became so depressed that on one occasion she jumped from her studio window (her fall was broken by a bicycle).

She lost herself in other ways as the 1960s progressed. For one piece in 1966 she walked though some of the rougher neighbourhoods of the city, dressed in full Japanese national costume: kimono, white painted face, her plaited hair fixed with flowers and carrying an ornate parasol. The odyssey is captured in photos. Partly Kusama wanted to present herself as an outsider. Partly she wanted to project her singular identity as far and wide as she could (she had a Warhol-esque mania for fame). She hijacked the 33rd Venice Biennale in 1966 with Narcissus Garden, a lake of 1,500 reflective balls in which the viewer’s face was infinitely multiplied. She sold the balls for $2 each, “your narcissism for sale” read the ad, a gesture that foretold the artwork as selfie. The Biennale authorities stopped the performance, objecting to “selling art like hot dogs or ice-cream cones”.

When the summer of love arrived, Kusama sought to position herself as a kind of high priestess of flower power, staging “Body Festivals” and “Anatomic Explosion happenings” in which she painted naked partygoers with polka dots. She took these happenings to sites around New York – opposite the New York Stock Exchange, on the steps of the Statue of Liberty – creating nude protests against the election of Richard Nixon and the Vietnam war. Jeanette Hart, one of her dancers in these performances, recalls how she first heard about Kusama from a friend, who said the artist would let Hart stay at her studio for nothing if she could paint her. “I was thinking ‘portrait’,” Hart remembers. “It never occurred to me that it meant literally ‘paint me’.” Kusama’s happenings appeared on the front page of the Daily News twice in one year: “Nudies dance on Wall St and the cops don’t pinch ’em.”

A scene from Heather Lenz’s new documentary, Kusama: Infinity. Photograph: Dogwoof films

On 25 November 1968 she staged – half a century ahead of its time – New York’s first “homosexual wedding”, for which she had created a “wedding dress for two”. She sold polka dot fashion designs from a boutique, with holes to reveal breasts and buttocks, which cemented her notoriety not only in America but also in her native – and deeply conservative – Japan. She was the scandalous exile. Media interest in her work had shifted from serious critical attention to exposés in the tabloids where her name became synonymous with skin painting and orgies.

As the 70s backlash against 60s excesses began, and having become something of an outcast in New York, Kusama returned to Japan. She was deeply affected by the death of Joseph Cornell in 1972, and by her father two years later. She rented an apartment on the 10th floor of a tower block in Shinjuku, Tokyo, overlooking a large cemetery, and began to work on an elegy to Cornell in surreal collages. The hallucinations and panic attacks of her adolescence returned with full force, however, and she was hospitalised several times. In Lenz’s film there is some footage from an art project that saw Kusama alone in a park in the city, submerged under a seething pile of silk, unable to escape. In March 1977 she admitted herself to a psychiatric hospital.

For some artists this might have been the end of things, but for Kusama it represented a new start. She found a way to manage her mania, and direct it toward her creativity. The hospital offered art therapy courses. She signed up, and never left.

Kusama does not do interviews, but in the course of researching this story I was invited to ask her three questions about her curious life by email. What do you say? This businesslike exchange went as follows: “Was the enormous recognition you have received relatively late in your career a surprise to you? Did you ever lose faith in it happening?”

“Long ago,” Kusama wrote back, “I decided that all I could do was express my thoughts through my art and that I would continue to do this until I died, even if no one was ever to see my work. Today, I never forget that my artworks have moved millions of people all around the world.”

What have been the advantages for you of living in a psychiatric hospital? How has it informed your practice as an artist?

“It made it possible for me to continue to make art every day, and this has saved my life.”

How do you habitually begin your days in the studio? And how do you end them?

“I have been painting, drawing and writing from morning until night every day since I was a child. When I arrive at my studio in the morning, I put on my work clothes and start to paint straight away, and I work right up until dinner time. I don’t rest. I am an insomniac. Even now, if an idea comes to me in the middle of the night, I pick up my sketchbook and draw.”

Heather Lenz asked to film at Kusama’s hospital but it was not possible, out of respect for the other patients. Having had this brief exchange with Kusama, I wondered what Lenz made of her curious regime?

“I think it was her choice – and that is in no way to belittle any of her traumas or her medical conditions. If you think about it, she had found this location where she was looked after and there was art therapy and it was close to her studio. She wanted to spend her time making her art – and here was a situation where she didn’t have to worry about washing her sheets or cleaning the bathroom or cooking. It is not a bad arrangement. If you look at the history of art, a lot of successful men have had wives or servants do that for them also.”

Kusama sleeps at the hospital each night and works in her studio across the road six days a week. She eats sushi from the local supermarket. She makes her own clothes. She apparently has little interest in the wealth that has come to her late in life. She has a small team of assistants in her studio, and gallerists who look after her interests in New York, Tokyo and London. Glenn Scott Wright, co-director at Victoria Miro, is one of them.

Visitors at Kusama’s Kusamatrix exhibition in Tokyo, 2004. Photograph: Junko Kimura/Getty Images

Scott Wright recalls how he first saw Kusama’s art at Modern Art Oxford in 1989. “I just walked in not knowing much about her and thought ‘these are absolutely amazing’.” He sought out more of her work at an exhibition at the CICA museum in New York later that year, the start of Kusama’s triumphant resurrection in the city, curated by Alexandra Munroe. The first time Scott Wright encountered her in person was at the 1993 Venice Biennale, when she was granted the whole Japanese pavilion. He has watched her star slowly rise over the past 25 years.

“We had an Infinity Mirror Room at the first Victoria Miro show at Cork Street [in 1998] and practically no one came. The last show we had 80,000 visitors.”

One reason for this success, he believes, is the need to make amends in some way for the fact that Kusama was never taken up by the art establishment like her male contemporaries. “She was doubly an outsider – a woman, and a Japanese woman. She just wasn’t recognised in the way the white male artists were. In retrospect it is clear she was a very important figure both in minimalism and in pop art. Her work provided a link between the two, which was unique.”

As well as that, he argues, Kusama has achieved the rare double of serious critical attention and immense popularity. “At the same time as the Tate retrospective was happening in 2012, including all this wonderful work from the 1950s and 1960s, she was launching a fashion range with Louis Vuitton, perhaps the biggest art and fashion collaboration ever, with thousands of shop windows. I think the nature of her work is that it has always had the capacity for universal appeal. Even from the early shows you could observe people of all ages opening up to it with a real sense of wonder.”

Scott Wright goes to see Kusama regularly in Tokyo, probably three times a year. Generally the artist is painting when he arrives at the studio and he waits to let her finish before they discuss any business.

“She paints on a flat surface and sits in a chair, but she will get up and move around,” he says. “She is not much interested in hearing art world gossip, she wants to talk about her own work.”

I wonder how changed she is by success?

“She doesn’t talk about it so much, but she says she always wanted Kusama to be everywhere, so she appreciates that.”

The internet has granted Kusama that wish in ways she could not have imagined when she was sitting in her field of peonies as a girl. “I am determined to create Kusama world, which no one has ever done and trodden into,” she once wrote. As a student of narcissism she would perhaps have been amused to hear that one visitor to All the Eternal Love I Have for the Pumpkins recently took that desire literally when he stumbled into and shattered a pumpkin while trying to capture a self-portrait in a mirror.

Yayoi Kusama: The Moving Moment When I Went To The Universe, is at Victoria Miro gallery, London N1, 3 Oct-21 Dec. Free timed tickets: victoria-miro.com. Kusama: Infinity, is in cinemas/on demand from 5 October.

There will be a private view for readers of the Observer (the Guardian’s Sunday sister paper) on 14 Nov. Details of how to apply for tickets will be published in the Observer next month