In the fall of 1939, Josephine Baker stepped onto a stage unlike any other she’d graced in her sizzling career. Hoping to improve the morale of the troops who manned the Maginot Line, the massive defensive structure that guarded France’s eastern border, the French high command had asked her to perform a series of shows. The bunkers and barracks were a far cry from the blazing lights of Paris’s Folies-Bergère or the Casino de Paris where Baker dazzled audiences with her graceful dancing, comedic timing, and barely-there costumes. Her shows gave the troops a reprieve from watching the German border and wondering when the Wehrmacht might strike. Instead, the men hooted and hollered as the 33-year old Baker sang and slinked her way through a series of French chansons.

Maurice Chevalier, who had made a career of musical comedy in Paris and Hollywood, joined Baker on the tour. The fifty-something Chevalier, sporting his trademark straw hat, insisted on going second, intending to finish the show in grand style. He didn’t count on Baker’s receiving calls for encore after encore, cutting into his performance time.

The soldiers responded to Baker the same way Paris had ever since the ambitious African-American girl from St. Louis charmed the city with her comedic sensuality. After a hardscrabble childhood in St. Louis, Baker found her way to headline La revue nègre at the Théâtre des Champs-Élysées in 1925. The daring show, which featured Baker dancing in nothing but a feather skirt, set Paris talking—and it hadn’t stopped since. Parisian society also welcomed Baker, giving her a level of freedom and acclaim that her country of birth could barely imagine, let alone offer. She embraced it all: the men, the jewelry, the clothes, the grand houses. She sauntered down the Champs-Élysées with her pet cheetah on a leash. She even gave product endorsements. When Casablancans opened their newspapers and magazines, they saw ads for Bakerfix, a crème “to keep your hair supple, brilliant, and in place,” available at Casablanca’s finer salons.

In December, Baker and Chevalier returned to the stage together at the Casino de Paris, the legendary red-velvet music hall in the ninth arrondissement. Rationing, curfews, travel permits, sandbags around monuments, sweethearts kissing loved ones farewell, and daily stories about war preparation dampened Paris’s joie de vivre. Inside the Casino de Paris, the halcyon days still reigned as people filled the theater to the rafters to see Paris-Londres, a revue celebrating Anglo-French friendship. The show—“a new spectacle of rhythm, charm, and beauty”—featured 32 “beautiful women” from Paris and London, along with performances by Chevalier, Baker, and Nita Raya. Chevalier opened the review with “Paris Will Always Be Paris,” while Baker closed the show with “Mon coeur est un oiseau des îles.” The sentimental song, in which she likens her heart a tropical bird, could melt even the hardest soldier’s heart.

The opening-night performance of Paris-Londres raised money for charity, with Baker’s portion going to the French Red Cross. Baker participated in other charity shows, including one at the beginning of February 1940 with Edith Piaf, Alibert, and other music hall icons. During the day, Baker worked in a shelter on the Left Bank for homeless refugees, continuing a long-standing habit of helping those less fortunate than her. “My heart sank at the sight of those exiles, broken body and soul by defeat,” she wrote.

Baker also began working for the Deuxième Bureau, the French intelligence service, after being recruited by Jacques Abtey, who sought “honorable correspondents” who could feed his organization information about what they heard and observed: who met whom, who had tense conversations in corners at parties, who struck up unusual friendships. In the aftermath of Germany’s invasion of Poland and its alliance with the Soviet Union, France’s security services became obsessed with Fifth Column threats. A theatrical agent, Daniel Marouani, suggested that Abtey consider using Baker, telling him, “She is more French than the French.” With her extensive social connections and adoring fans, Baker could be a trove of information.

Abtey agreed to meet Baker at Beau Chêne, her home in the Paris suburb of Le Vésinet. There, instead of a starlet, he encountered a woman in a battered hat collecting snails from her garden to feed her ducks. The glamour came next, when Baker invited him to join her in the salon, where a white-jacket-clad servant poured them champagne before a roaring fire. “‘France made me what I am,’ she told him. ‘The Parisians gave me their hearts, and I am ready to give them my life.’” It also didn’t hurt Abtey’s cause that he sported Nordic good looks—“young, blond, athletic, bursting with life,” as Baker described him—and was exactly her type. Baker became both his lover and his student.

“ 'Sometimes she would write along her arms, and in the palm of her hand, the things she heard. I told her this was dangerous, but she laughed. "Oh, nobody would think I’m a spy."' ”

“When I gazed deep into my own inner self, I realized that I would be incapable of functioning as a real spy,” wrote Baker. “But intelligence work was different. It seemed the perfect way to fight my war.” It didn’t take long for Baker to start passing along information gleaned at receptions at the Japanese and Italian embassies, parties she personally threw, and other affairs around Paris. “Sometimes,” Abtey said, “she would write along her arms, and in the palm of her hand, the things she heard. I told her this was dangerous, but she laughed. ‘Oh, nobody would think I’m a spy.’”

Following the fall of France in 1940, Baker and Atbey found themselves hiding out—comfortably—in Les Milandes, Baker’s estate in the southwest corner of the country. It was there that they received a courier from Captain Paul Paillole—Atbey’s former boss who was now masterminding an underground intelligence network in Vichy—with a mission. Paillole wanted Abtey to go to Portugal and make contact with British intelligence. But he remained leery of Baker. “I was afraid that she was one of those shallow show business personalities who would shatter like glass if exposed to danger,” said Paillole. Despite his reservations, he agreed to give her a chance.

According to the cover story they devised, Baker was embarking on a tour of Portugal and South America. Given that Germany had swallowed up most of western Europe, it would be logical for Baker, an international star, to look to neutral Portugal and the untouched countries of South America for bookings. Abtey, posing as her ballet master, became the 41-year-old Jacques-François Hébert. Abtey, who was really 35, had to be aged because no man under 40 was permitted to leave Vichy. To make himself look older, Abtey wore glasses and donned a heavy moustache. Assessing the starlet and her middle-aged ballet master, Paillole declared himself satisfied. “You look good together,” he said. “Good luck.”

To reach Portugal from Vichy, they needed transit visas for Spain. Baker worked her magic, charming a reluctant Spanish consul in Toulouse into giving them the needed paperwork. She did the same at the Portuguese and Brazilian consulates.

The duo performed so well in the field that they were given a new mission in December 1939: to go to Casablanca and set up a liaison station, where they would relay messages and intelligence between Vichy and London.

By the end of January 1940, Baker and Abtey were in Casablanca. As they made plans for Baker to return to Portugal to continue her intelligence gathering, they encountered a roadblock: the Portuguese consulate refused to issue Abtey a visa for Lisbon. Baker even tried the damsel-in-distress argument—“how would I manage the details without him?”—but the consul held firm. Abtey was stuck in French Morocco.

Back at their hotel, they debated about what to do next. “Do you think they may have blown your cover, Jacques?” she asked. Abtey didn’t think so, but they needed to press forward. “We decided,” wrote Baker, “that I would have to travel to Lisbon alone. Taking my sheet music, of course.”

At the end of February, Baker took the train north to Tangier, where she could catch a flight to Lisbon. While in Tangier, she renewed friendships forged during the filming of Princesse Tam-Tam, shot on location there and in Tunisia in 1935. She spent a few days at the villa of Abderahman Menebhi, the sultan’s brother-in-law, where she also saw Ahmed ben Bachir, the court chamberlain to the caliph of Spanish Morocco. With influential friends and a command of Spanish, Baker was also poised to gather information about Spanish Morocco.

By the beginning of March, Baker was back in Lisbon, where posters with her face plastered walls and kiosks around the city, announcing her upcoming shows. She needed every seat filled; her take of the box office receipts had become increasingly important. Financial restrictions made it difficult to get money from her bank accounts in Paris, putting a damper on her normally extravagant tastes. Between rehearsals, Baker lobbied for a visa for Abtey. She also collected bits of intelligence from sources who found their way to her, along with information she amassed from loose-lipped diplomats and Axis officials. She returned to Morocco at the end of March with messages from Paillole to Abtey pinned inside her bra. And once again, notes written in invisible ink covered the back of her sheet music. She didn’t, however, have a visa for Abtey.

For the next few months, Baker flitted back and forth between Casablanca and Lisbon, Seville, Madrid, and Barcelona. Between performances, she accepted invitations to parties and embassy functions, where she hobnobbed with the elite and diplomats. And as she bantered over champagne and twirled around the dance floor, she continued her intelligence gathering, transporting the information back to Abtey.

Excerpted from Destination Casablanca: Exile, Espionage, and the Battle for North Africa in World War II by Meredith Hindley. Copyright © 2017. Available from PublicAffairs, an imprint of Perseus Books, LLC, a subsidiary of Hachette Book Group, Inc.