SAINT-LÔ, France—On the evening of June 6, 1944, U.S. bombers appeared in the skies over this town in Normandy, targeting a command center of the occupying German army.

The Americans had dropped leaflets warning civilians to evacuate, but the wind blew them astray. Yves Fauvel , 6-years-old at the time, and his family were eating dinner when a bomb fell next to their house. They quickly took shelter in their basement as bombs began to thunder around them. When they emerged hours later, much of the town was in ruins and hundreds were dead or dying.

“Everything was on fire,” Fauvel said, “people wailing, imprisoned in their basements—they couldn’t get out.” The 86-year-old has only recently begun telling his story after decades of silence, as France prepared to commemorate the 80th anniversary of the D-Day landings. “People weren’t interested. It was terrifying. It’s like having a serious illness—if you haven’t had it, you can’t comprehend,” he said.

Born in the fires of World War II, the trans-Atlantic alliance is facing its most difficult test since the collapse of the Soviet Union. The U.S., France and other countries in the North Atlantic Treaty Organization have banded together to support Ukraine in its war with Russia and send a signal to Moscow that they are prepared to defend against a direct attack. President Emmanuel Macron is set to host President Biden and other NATO leaders on Thursday for an elaborate celebration of the landings, a show of unity after more than two years of war in Ukraine .

But Macron is also shining a light on the traumatic origins of the alliance. On Wednesday, the French president commemorated the more than 50,000 civilians who died from American and British bombing during the war with a speech in Saint-Lô, which the Irish playwright Samuel Beckett called “The Capital of Ruins” in an essay published in 1946 after visiting the town.

“The city, with its train station and garrison of 1,500 enemy soldiers, was a necessary target,” Macron said. “Saint-Lô, the martyred city, sacrificed to liberate France.”

France’s place in the trans-Atlantic alliance hung in the balance as it emerged from the ashes of the war. The U.S., British and Canadian soldiers who fought on the beaches of Normandy arrived in a country where many people were mourning the dead and living amid the ruins.

Sympathy for the Soviet Union ran high, because of the immense sacrifices of Soviet soldiers on the eastern front and the strength of the French Communist Party. Gen. Charles de Gaulle would soon attempt to stake out France’s independence from the U.S., signing a mutual cooperation treaty with the Soviet leader Joseph Stalin in December 1944. In May 1945, a poll of the French public found that nearly 60% of the public credited the Soviet Union with doing the most to defeat Germany; only 20% said the U.S.

“You will never know what faith in our Allies it took to continue to love them, to want with them the destruction they wrought on our soil, in spite of everything,” the French philosopher Jean-Paul Sartre wrote shortly after the war.

Eighty years later, France is now firmly ensconced in the alliance, despite the  occasional argument  with Washington. Macron has emerged as one of the West’s most outspoken hawks against Russian aggression in Ukraine. Biden landed in Paris on Wednesday for the D-Day commemoration and a series of meetings with Macron and other allied leaders, including Ukrainian President Volodymyr Zelensky .

French officials say the time is ripe for a clear-eyed understanding of the history of the allied landings and the liberation. This year is one of the last chances to gather eyewitness accounts of the events before the remaining survivors die off.

“It’s deeply painful when you have a memory of a tragedy that isn’t relayed, recognized by the collective memory,” said French historian Denis Peschanski , who is in charge of the organizing committee’s scientific advisory board.

Britain had been bombing France sporadically since the beginning of the German occupation in 1940. The bombing intensified in 1943 after the U.S. entered the war.

In 1944, the allies launched the Transportation Plan, a bombing campaign that sought to destroy French rail infrastructure used by German forces to move supplies and men around France. The bombing took aim at cities and targets across the country, from Marseille to Lyon up to Normandy.

British Prime Minister Winston Churchill and his adviser Anthony Eden began to worry that the civilian casualties during these raids would turn the French against the Allies.

“Eden was saying the French are already turning to the communists and this is going to make it worse,” said Andrew Knapp , a British historian who has written extensively about the allied bombing campaigns.

On June 6, 1944, Robert Edward Pedigo , was the nose gunner of a bomber that flew over the English Channel. Looking down he saw an armada of boats so dense that they appeared to form a bridge to Normandy. His mission on D-Day was to bomb a German encampment, but in the weeks to come he and his crew would also hit Saint-Lô.

“Many people died, but we saved millions,” said Pedigo who, at 100 years old, set foot in Normandy for the first time this week.

When allied soldiers and aviators finally landed in Normandy, some were shocked at the destruction they had wrought. Bill Wall , who manned a radio and antiaircraft guns on a U.S. bomber, spent much of the war flying missions over France and Germany, including on D-Day. He touched down once in Normandy to refuel.

“I saw the buildings we had just destroyed,” said Wall, who turned 101 on Wednesday and returned to Normandy this week for the first time since the war. “I felt good but also, what a waste to destroy something like that.”

Many in Normandy were left homeless, and some confronted tragedy. In Coutances, a Norman town near the coast, a U.S. bomber dropped a bomb on the house of the family of André Laurent on June 6, 1944, killing nine people, including uncles, aunts and his grandmother. Laurent, who was born a year later, grew up with photographs of the nine dead family members in an oval portrait hanging in the living room. Every June 6, the family attended a ceremony at the town cemetery to commemorate the civilian victims of the war.

“It wasn’t specified that this was due to the American bombing,” Laurent said. “But my mother had a strong resentment toward the Americans, more so than the Germans, which is understandable…. We told her, OK, but these are indirect effects of the war.”

“The Americans were our liberators; we must recognize this,” Laurent added.

In the decades that followed, the commemorations of D-Day were muted as France mourned the dead and rebuilt after the war.

For the 20th anniversary of the landings in 1964, de Gaulle, who was president, didn’t attend D-Day ceremonies. Instead, he paid tribute to the allied landing in Provence on Aug. 15, 1944, because the Free French forces played a far larger role in that operation than in D-Day. Two years later, he pulled France out of NATO’s military command, saying the arrangement undermined French sovereignty.

In 1984, President François Mitterrand raised the profile of the D-Day ceremony, deciding to embrace the U.S. and Britain. Mitterrand invited President Ronald Reagan and Queen Elizabeth II among other dignitaries for a memorial at the American cemetery in Colleville-sur-Mer.

French public opinion began to shift, viewing the U.S. and not the Soviet Union as the main conquerors of Germany. In 2009, President Nicolas Sarkozy brought France back in to the NATO military command . By 2015, more than half of French people said the U.S. was the main contributor to the defeat of Germany, while only 23% said it was the Soviets, according to a poll by French polling firm IFOP.

Nowadays, Fauvel, who survived U.S. bombing at age 6, has a small American flag displayed on the inside of his car’s windshield.

“I say thank you to Americans all the time,” Fauvel said. “Without them, we would be Germans.”

Write to Matthew Dalton at Matthew.Dalton@wsj.com and Noemie Bisserbe at noemie.bisserbe@wsj.com