In the summer of 1968, Valerie Solanas, a disgruntled bit player on the New York arts scene, broke into Andy Warhol’s office and shot him twice with a .32 Beretta. The bullets punctured Warhol’s lungs, stomach, liver and spleen, cutting the Pope of Pop down at the peak of his fame. Doctors briefly pronounced him dead at the scene.

Warhol recovered – but he was never the same. He turned his back on the in-crowd and embraced high society. He balanced lucrative portrait commissions with melancholy abstracts that left the critics unmoved. “I stopped being creative when I was shot,” Warhol would lament, although one wonders if this is entirely true. More likely he embarked on a tactical retreat. He wanted to dismantle his image and script his own exit line, an impish control freak right to the end.

Godfather of the meme … Warhol’s Self-Portrait, 1964. Photograph: Andy Warhol Foundation for the Visual Arts/ARS New York

Now Warhol is back, after a fashion, in the form of a blockbuster retrospective at the Whitney Museum of American Art. From A to B and Back Again (America’s first Warhol retrospective in nearly 30 years) bulges with more than 350 works (paintings, sketches, films and video). It rattles us from the artist’s early apprenticeship as a fashion illustrator, through his 1960s heyday and finally deep into middle-aged marginalia. Except that – suddenly, perversely – the later work isn’t marginal at all. If anything, it now looks as radical and intriguing as his silk-screen Marilyns and Campbell’s Soup Cans.

“The pop art is extraordinary but it’s frozen in time,” explains chief curator Donna De Salvo, who collaborated with Warhol in the mid-1980s. “For me, the most potent stuff is the later work. Some of it is mystifying, but it’s still asking us questions. It feels as though it makes Warhol a live issue again.”

If Warhol changed after the 1968 shooting, Manhattan has too. The Factory’s long gone, downtown’s full of money and the Whitney sits in the old meatpacking district, where the pork and poultry suppliers have been edged out by designer stores and boutique hotels. But inside at the press view, the Velvet Underground’s Heroin spills from the speakers, while the screens play host to his shaky 16mm films (Eat; Kiss; Empire). It’s like stepping into the best kind of New York haunted house.

The journalists make a beeline for the most famous stuff. They’ve seen it 100 times already. Maybe that’s part of its appeal. Warhol liked to use repeated motifs. He wanted to hit the pause button on the flow of 20th-century production and invite us to consider the brand as high art. So here’s his Triple Elvis and his Marilyn Diptych; his 32 flavours of Campbell’s Soup and his multiple Mona Lisas (30 Are Better Than One, reads the title). The guests gather at each canvas, iPhones held aloft. They’re making reproductions of paintings that are themselves reproductions. Probably the artist would be tickled by that.

Crisis of faith … detail of Camouflage, 1986, with a print overtop Da Vinci’s The Last Supper. Photograph: Andy Warhol Foundation for the Visual Arts/ARS New York

Warhol died in 1987 during routine gallbladder surgery. The Solanas attack had weakened his constitution. These days his cultural influence hardly needs to be stated, but the Whitney curators are leaving nothing to chance. Down in the lobby, they talk about how he was practically the internet before the internet existed. How he embraced new technology; how his manipulation of existing images make him the father of the meme; how his recording and enshrining of day-to-day ephemera was an embryonic Instagram. Some inevitably cite his line about everyone being famous for 15 minutes as his great Nostradamus moment, a prediction that feels only more true with each passing year.

“Andy matters now more than ever,” says Bob Colacello, a Warhol biographer who also edited Interview, the artist’s magazine, between 1971 and 1983. “That’s because Trump is president and the Kardashians are at the White House and we basically have a reality-TV administration.”

Warhol and Trump crossed over in the 80s. One was in decline and the other on the rise. Both were united by a fascination with celebrity and tickled by the notion that making money might constitute a creative act in itself. “Good business is the best art,” Warhol once remarked, and Trump liked the line so much that he’d quote it and adapt it in his own books. In 1981, he commissioned Warhol to produce a series of silkscreen portraits of the newly constructed Trump Tower. Warhol delivered. Trump never paid up.

“Andy was a liberal Democrat, more or less,” says Colacello. “But he liked celebrity and could be swayed by that. So he’d have a very Andy-like response to Trump being president. He’d say, ‘Ooh, Donald’s such a big star now. But I still hate him because he never paid me for the Trump Tower pictures’.”

Haunting … paintings from the series Shadows, 1978–79. Photograph: Bill Jacobson Studio/Dia Art Foundation/Andy Warhol Foundation for the Visual Arts/ARS New York

Warhol took hundreds of portrait commissions during his last 20 years. He would charge $25,000 a pop and toss off hyperreal silkscreens of financiers and sheikhs, socialites and celebrities. Together, these pictures helped harden public perception of the artist as a has-been, a sellout, a society painter for the spoilt 1% – and this prejudice certainly contains a nugget of truth. But the selling out was only half the story, because Warhol channelled his earnings into more personal, experimental work, and it is here that the Whitney’s retrospective takes its fascinating last turn.

In his declining years, it seems, Warhol was drawn to themes of death and concealment. He painted coloured skulls and Rorschach blots and military camouflage print that he then threw across a reproduction of Leonardo Da Vinci’s Last Supper. Best of all is his haunting series of 102 shadow paintings – 58 of which are being shown further uptown, in Calvin Klein’s HQ near Times Square. Warhol’s pop art is defined by its sense of mischief and provocation. But the Shadows series is intimate, meditative and deeply moving. I’m not sure I’ve ever been moved by his work in the past.

De Salvo says that no one much wanted Warhol’s 70s and 80s output. It was seen as garbled, impenetrable and somehow at loggerheads with his previous work. But she regards this as the logical last step on his journey as an artist. “People think of Warhol as celebrating the image, with his pictures of Marilyn and Elvis and Jackie Kennedy,” she says. “But the trajectory of his career was actually about destabilising the image. He reproduced it, he obscured it, he wanted to see if he could make the image unravel. And that’s what he’s doing with this last set of pictures. Maybe he was having a crisis of faith. Who knows? But the result was this interesting new direction towards abstraction, camouflage and concealment.”

Themes of death … Rorschach, 1984, by Andy Warhol. Photograph: Patrick McMullan via Getty Images

Just a few minutes earlier we were gawping at 30 Are Better Than One, that pop-art spectacular with its recurring Da Vincis. Now we’ve arrived at Sixty-Three White Mona Lisas, a companion piece of sorts, which Warhol painted towards the end of his life. The first painting was jaunty and bountiful; one in the eye for the gatekeepers of high culture. But the second is different: it feels downbeat, fatalistic, rubbed out.

People think of Warhol as celebrating the image, but his career was about destabilising it

The Mona Lisa starts as out a ghostly image at the top-right corner and then proceeds to fade out slowly by degrees until, by the bottom left, there is barely anything left to see. “Look,” says De Salvo, “the picture’s disintegrating.” She feels that’s a pretty bold statement from the man who understood the power of a good image probably better than anyone; a reminder that the pictures are not to be trusted; that images warp and icons deteriorate. It’s as if Warhol’s grand final trick was an act of erasure. He wanted to wave his magic wand and make himself and his work disappear.

That night the Whitney hosts an exclusive VIP party. The line stretches down the road and around the block; Warhol’s definition of celebrity always was quite relaxed. We stand at the bar and watch them come in: black and white, old and young, doddery relics of the Factory scene beside box-fresh representatives of the meme generation. The mood is festive and the din is terrific, and still the man’s acolytes and descendants keep pouring through the door. They provide human cover, a fresh coat of paint. Presumably, this is just as Warhol would want it. When the gallery has filled up, you can’t see the art.