In May 1961, an elderly woman in Paris heard a knock at the door of her six-story walk-up apartment. It was only the most powerful man in the world.

The president of the United States was going door-to-door hoping to find the call girl he had discreetly arranged to meet.

John F. Kennedy, it turned out, used a fake excuse about a doctor’s visit to attend a long-arranged dalliance while in Paris for a crucial summit, only to wind up in the wrong building, knocking on the doors of random Parisians who were left with the surprise of their lives.

The tale of this ill-advised but ultimately, er, successful liaison is recounted in “Madame Claude: Her Secret World of Pleasure, Privilege, & Power,” by William Stadiem (St. Martin’s Press).

Madame Claude, born Fernande Grudet on July 6, 1923, in Angers, France, was one of the world’s most successful madams.

Starting in 1957, she ran an exclusive, high-class prostitution ring that offered a very specific type of woman — tall, supermodel-gorgeous, classy and upscale (or at least trained to appear so) — to the world’s richest and most powerful men.

The young women who worked for her were known as Claude girls, which became a well-known and powerful brand. She scouted them carefully, paid for plastic surgery if needed, and ultimately hoped to marry them off to aristocracy.

“A date with a ‘Claude girl’ was one of those pinnacle Paris experiences,” writes Stadiem, “like staying at the Ritz or dinner at Maxim’s or wearing a Lanvin suit . . . an apotheosis of luxury that the French do better than any other nationality.”

According to Stadiem, Madame Claude’s client list included the world’s most successful men of the time: Kennedy, Frank Sinatra, Pablo Picasso, Marc Chagall, Sammy Davis Jr., former Vice President Nelson Rockefeller, three generations of Gettys, the Shah of Iran, Marlon Brando, Darryl Zanuck, Groucho Marx. If you were rich, famous and male in the 20th century, chances are Madame Claude knew what you liked in bed, and provided exactly that.

For Kennedy, his desired liaison required almost as much detailed preparation as an actual political summit.

After the Bay of Pigs fiasco in April 1961, Kennedy thought a meeting in Europe with French and Soviet leaders Charles de Gaulle and Nikita Khrushchev, respectively, could serve as a reset for his presidency. He decided that he and first lady Jackie Kennedy would embark on their first official European tour. This would be the trip where Jackie so entranced the French that Kennedy famously introduced himself as “the man who accompanied Jacqueline Kennedy to Paris.”

But while Jackie was thrilled at the prospect of meeting novelist and newly appointed French Culture Minister Andre Malraux, one of her literary idols, her husband looked to fulfill a different sort of fantasy.

“If JFK had a type, it was the wholesome, snooty, proper, preppy girl whose flaunted untouchability he could violate . . . girls like Jacqueline Bouvier,” writes Stadiem, who notes that Kennedy learned about Madame Claude from Sinatra.

“Here was a madam who specialized in exactly what JFK was after.”

The liaison, Stadiem writes, was arranged directly between Madame Claude and Pierre Salinger, Kennedy’s press secretary. When Salinger first proposed the arrangement, Claude turned him down, fearing the many things that could go wrong if the president’s visit to a prostitute went haywire.

But Salinger, the brains behind many of Kennedy’s most impactful speeches, convinced Claude that any problems could work in her favor — that a scandal would make her a legend to the sex-comfortable French, and that a successful dalliance would bring her to the attention of the world’s most powerful men.

“‘Rise to the occasion,’ Salinger exhorted Claude. ‘Do it for your career. Do it for your country,’ he riffed, paraphrasing JFK’s inaugural address. ‘Think big!’ ” Stadiem writes. “Weighing risks and rewards like the shrewd banker she might have otherwise been, Claude decided to go for it.”

On the trip, Kennedy hoped to hook up with French actress and Jackie Kennedy-lookalike Anouk Aimée, who had just appeared in the Federico Fellini hit “La Dolce Vita.” The president, Stadiem writes, had been “obsessed about her.”

“What does he want her for? He’s already got her,” Claude, referring to Aimée’s resemblance to the president’s wife, asked Salinger.

“The explanation was that JFK liked the package more than the contents,” Stadiem writes. “He was drawn to Jackie’s looks but wanted a more seductive, sexual version.”

Aimée, however, was horrified at the suggestion, rejecting it outright — not for any reticence about a paid encounter, but because she considered Kennedy a “puerile warmonger.” Claude told Salinger only that she was away on business and, therefore, unavailable.

While Claude searched for a suitable replacement, Kennedy and Salinger spent much of their time in the month before the summit determining how they would fit this diversion, for which they had a maximum of one hour, into the two-day trip without anyone finding out. They even had a code, speaking about “buying Jackie a gift saddle at Hermès” whenever they needed to discuss the side excursion.

“If the world had any idea how much of his time was focused not on NATO or Algeria or Vietnam, but on a hot date from Madame Claude, the perception of history would have been dubious, to say the least,” Stadiem writes.

Claude found Kennedy’s dream date in a 23-year-old Sorbonne graduate who worked as a fitting model for Givenchy.

That last detail added an intriguing element to the liaison. Kennedy and the first lady fought incessantly about the trip, as the president wanted the former Ms. Bouvier to dial down her natural “Frenchness” and reflect a more American image. On this front, Jackie thought her husband should stuff it. Salinger and Claude, aware of this, both thought that a Jackie lookalike adorned in a dress from the most French of designers would be like “waving a red cape at a bull; the bull was sure to charge, as was the president.”

For secrecy’s sake, it was determined that the dalliance would take place at the young woman’s apartment.

After Kennedy spent the first day with de Gaulle, the plan for Day Two was for Malraux to play tour guide to the first lady while the president visited French historical sites. But at the last minute, Kennedy begged off, claiming a flare-up of his infamously bad back and saying that he’d need to visit a French pain specialist.

In reality, Kennedy had brought his doctor, Max Jacobson — the infamous Dr. Feelgood who injected a slew of celebrities and dignitaries, including the president, with amphetamines — for cover, and they headed off to find his mystery lover, only to wind up at the wrong apartment.

After walking up six flights, the president spent five minutes pounding on the door he thought would lead to his exciting mystery date, only to get no answer. He then knocked on several neighboring doors and gave a few old ladies the surprise of their lives before he dejectedly trudged back downstairs.

Kennedy donned a fedora as a disguise and walked into a local cafe hoping to find a pay phone so he could call Salinger and find out what went wrong. He managed to walk unrecognized into the cafe, but saw that their pay phone required tokens, leading to a surreal scene.

“JFK had to slither up the narrow, curving stairwell and abashedly request a token from the grizzled bartender, who gave him the most curious and dubious of looks,” Stadiem writes.

“Neither he nor Dr. Jacobson had any francs. JFK had no money at all. Jacobson fished out a twenty-dollar bill and gave it to the barman, who seemed mystified. The doctor motioned for him to keep the change.”

When Kennedy finally reached Salinger, it turned out the legendary speechwriter was less proficient with addresses — he had written “boulevard de Courcelles” instead of “rue de Courcelles.”

Duly corrected, the president found the correct address and his Claude girl, decked out in the exact same Givenchy dress his wife would be wearing, displayed for the eyes of the world, that evening.

After receiving a shot of “medicine” in his back from Jacobson, Kennedy spent no more than half an hour with the young woman. According to Claude, Kennedy was so fascinated by the dress that his date “gave the president a striptease combined with a seminar.” That night, the president was “profusely complimentary to Jackie over her Givenchy.”

The rest of the trip was a success for Kennedy, as he held his own against the more experienced Khrushchev.

“Was it the vitamin shots that kept Kennedy’s spirits high and positive?” Stadiem inquires. “Or was it the sweet medicine of Madame Claude?”