Bill Millin was the "Mad Piper" who played allied commandos ashore under heavy German fire at Sword Beach in Normandy on D-Day, on the extreme eastern flank of Operation Overlord.

He was the only piper to lead allied troops into battle that day following a War Office ban which said pipers would attract sniper fire. But his commander, Brigadier Lord Lovat – Simon Fraser, hereditary chief of the Clan Fraser – was a law unto himself. "Ah, but that's the English War Office, Millin," Lovat told him. "You and I are both Scottish so that doesn't apply."

Millin recalled: "Lord Lovat said this was going to be the greatest invasion in the history of warfare and he wanted the bagpipes leading it." On the landing craft sailing out of the mouth of the River Hamble in southern England, "he said I was to play and he would worry about the consequences later."

Download the new Independent Premium app Sharing the full story, not just the headlines

The "Mad Piper" label came from both Millin's own comrades and the German defenders of Sword Beach at Colleville-sur-Mer, who said after capture that the only reason they didn't shoot him is that they thought "he must have gone off his head."

Although one man was shot dead alongside him on his landing craft, and he saw many of his comrades floating face down in the surf, he said the sound of his pipes drowned some of the gun and mortar fire. "I didn't really notice I was being shot at myself," he said. "The water was freezing. The next thing I remember is my kilt floating in the water, like a ballerina." He launched into one of Lovat's favourites, "Hielan' Laddie", as he waded ashore. Lovat, firing his old non-service issue Winchester rifle and brandishing a walking stick, gave him a thumbs-up.

On the beach, in the heart of the battle, Lovat asked him, "Would you mind giving us another tune, Millin? How about 'The Road to the Isles'?" Millin half-jokingly replied: "Now, would you also want me to walk up and down, Sir?"

"Aye, Millin, that would be nice. Aye, walk up and down."

The piper recalled the tremor of mortars in the sand as he walked up and down Sword Beach three times amid thick smoke and dead and wounded comrades yelling for medics. "When they heard the pipes, some of the lads started cheering but one wasn't very pleased and he called me 'the mad bastard'. Well, we usually referred to Lovat as the mad bastard but this was the first time I had heard it referred to me."

Millin, whom Lovat had appointed his personal piper during commando training at Achnacarry, near Fort William in Scotland, was the only man during the landing who wore a kilt – it was the same Cameron tartan kilt his dad had worn in Flanders during the Great War – and he was armed only with his pipes and the ceremonial Skean Dhu dirk sheathed inside his right sock. His exploits on that day, 6 June 1944, were immortalised in the star-studded 1962 Hollywood blockbuster The Longest Day, which showed his character ignoring sniper fire to lead Lovat (played by Peter Lawford) and the commandos of the 1st Special Service Brigade (1 SSB) over the Bénouville bridge, later renamed the Pegasus bridge. "It seemed like an awfully long bridge," Millin recalled. Lord Lovat was badly wounded six days later, ending his war, but he lived until 1995, when Millin played at his funeral.

Lovat's 1 SSB, including the Free French green beret commandos, had landed in support of British paratroopers of the 6th Airborne Division, who had landed by glider earlier and were involved in close combat with the bridge's defenders. In the film, one paratrooper says to another: "Listen ... I thought I heard bagpipes." "Don't be daft," his buddy replies before the "Mad Piper" marches across the bridge playing "Blue Bonnets over the Border". Contrary to many reports, the part of the piper was played not by Millin but by Major Leslie de Laspee, an official piper to Buckingham Palace at the time.

Born in Regina, Canada on 14 July 1922 to a father of Scottish origin who returned to Glasgow as a policeman when William was three, he grew up and went to school in the Shettleston area of the city. He joined the Territorial Army in Fort William, where his family had moved, and played in the pipe bands of the Highland Light Infantry and the Queen's Own Cameron Highlanders before volunteering as a commando and training with Lovat at Achnacarry along with French, Dutch, Belgian, Polish, Norwegian, Polish and Czechoslovakian troops.

Millin saw further action with 1 SSB in the Netherlands and Germany before being demobbed in 1946 and going to work on Lord Lovat's highland estate. In the 1950s he became a registered mental nurse in Glasgow, moving south to a hospital in Devon in the late '60s until he retired in the Devon town of Dawlish in 1988. He made regular trips back to Normandy for commemoration ceremonies and a 10ft bronze statue of him and his pipes is being completed in Colleville. He donated the famous pipes to the Pegasus Memorial Museum in Ranville, close to the Pegasus bridge, and France awarded him its Croix d'Honneur for gallantry. In 2006, a Devon folk singer, Sheelagh Allen, wrote a song about him, "The Highland Piper".

Millin, who suffered a stroke in 2003, died in hospital in Torbay. His wife Margaret (née Dowdel, from Edinburgh) died in 2000. He is survived by their son John.

William Millin, soldier and registered mental nurse: born Glasgow 14 July 1922; married Margeret Dowdel (died 2000; one son); died Torbay, Devon 18 August 2010.