In November 1914, acting under pressure from his German ally, the Ottoman Sultan Mehmed V, who doubled as Caliph of all Muslims, issued a holy commandment directed at Muslims worldwide: they were immediately to rise up in arms against Britain, France, Russia and their allies, who were at war with Germany and the Ottoman Empire.

Although the British took the threat seriously – this was "the parched grasses that awaits the spark" in John Buchan's celebrated phrase in his novel Greenmantle – the call to jihad was for the most part neglected. In the Caucasus, some Russian military came over to the other side. In Mesopotamia, a British officer had his throat slit. And in Singapore on 15 February, 1915, following rumours they might be sent to Turkey to fight fellow Muslims, there was a mutiny involving 850 Sepoys from the 5th Native Light Infantry Regiment of the Indian Army. The uprising was put down a week later, after 47 soldiers and civilians had been killed.

Aside from this handful of examples, the only other response to the Turkish sultan's call was in the least likely spot, on the other side of the world, in the Australian mining town of Broken Hill.

Two years ago, the Australian writer Murray Bail sent me a photo of an oil painting. It was by the artist Sam Byrne, who used to live in Broken Hill, and had the tantalising title Turks Fire on Picnic Train, 1 January, 1915. It pictured the only enemy action on Australian soil in the First World War.

The train was a steam train. The picnickers were in open trucks – sitting ducks. A young woman was killed, and three men. The two 'Turks' had been in an Afghan camel-driver team, and one had branched off into the ice-cream business. Clearly, they were not good shots. The men then ran away, and were gunned down by the cops.

Murray thought the story ideal for a novel. It was both old, yet contemporary, and not well-known. "And it would fit your normal impulse of not being able to write books about English people, in England; of preferring foreigners, in foreign parts. Of course, there is a lot to be ashamed about with English people, which I well understand; and writing a novel around this would avoid that."

Well, that hooked me. I'd been to Broken Hill before, on my first visit to Australia, in 1994, when driving through the outback to research a biography of Bruce Chatwin. I'd visited Pro Hart's gallery, with its painting ascribed to Titian, and fallen under the spell of the landscape and the people, who, with their unmined narratives of hardship, adventure and heroism, were reminiscent, I felt, of those I'd met in Patagonia. > So I decided to go back to Broken Hill and dig up what I could about the ambush. And what I found was a story that leads like a lightning rod into a conflagration which burns today with still greater ferocity, from Boston to Paris, from Woolwich to Sydney, and from Abu Bakr al-Baghdadi's self-proclaimed Isis caliphate to Mecca itself.

Even in Australian terms, Broken Hill – 852km north of Melbourne, 1,150km west of Sydney – feels a long way from anywhere. Yet in its boom days, the sweltering main street boasted more hotels than any city in the country. From the ironwork veranda of the Palace Hotel, where Priscilla, Queen of the Desert was filmed, I look out at the gigantic slag heap which dominates every street like a frown; grey and obdurate, 'the mullock' is an unavoidable reminder of the source of Broken Hill's phenomenal wealth in the early 20th century, when its minerals – chiefly zinc, silver and lead – were railroaded to Port Pirie and then shipped to Saxon smelters in Freiberg, 'the Mecca of ores', to make bullets for German guns.

Alma Cowie was shot on a New Year's Day outing in 1915 by two jihadis (Broken Hill Historical Society)

It was on a roasting morning like this, topping 30 degrees, that two disaffected Muslims decided to launch a suicide mission under a homemade Turkish flag. Their target: a train of 40 open ore-wagons carrying more than 1,200 holidaymakers.

At 10am on 1 January, 1915, the long and crowded train pulled away from the Broken Hill platform. It had been a town ritual since 1901: on New Year's Day, the Manchester Unity Order of Oddfellows, a friendly society founded to embrace education and social advancement, held a picnic 14 miles away in a shady creek in Silverton (where Mad Max was filmed).

Dressed in their best summer clothes, hundreds of light-hearted men, women and children chatted and waved as the train jolted forward and headed out towards the desert. Australia had been at war since August 1914 – some picnickers had brothers, fathers and sons in the Commonwealth Expeditionary Force which only weeks before had reached Suez. Yet today was a day to forget absent ones. On that Friday morning, few places on Earth were as peaceful as the red landscape surrounding Broken Hill, or so remote.

A solitary ore-wagon marks the spot, two miles out. All around, under the wide blue sky, stretches a flat expanse of stony, treeless desert dotted with wind-twisted, blackened vegetation and the skulls of gourds and paddy melon. Blink, and this might be the Holy Land.

Ten minutes after leaving the station, the train slowed down, the driver having been warned that sand had drifted across the line. The fireman was standing out on the footplate when he noticed a red cloth fluttering above a white cart. His first thought: someone's exploding defective ammunition. But he dismissed it. No one would be venturing out with a powder magazine on New Year's Day.

The white cart was parked close to the tracks. As the train steamed closer, the fireman read the words painted on the side – 'Lakovsky's Delicious ITALIAN ICE CREAM. A Food fit for Children and Invalids' – and relaxed.

"It's rather late for an ice-cream cart to be going out to Silverton," he observed.

The driver smiled. "I suppose some poor old beggar's hoping to make a bit for himself."

They chugged past. The driver noticed what looked like an insignia on the red cloth. Then a breeze sprang up, unfolding it, and he saw a yellow crescent like a banana, and a star.

At that moment, a pair of white turbans bobbed up from the trench and he heard two gunshots. One bullet hit the sand, spitting dust against the engine. The second bullet struck the brake-van, embedding itself in the woodwork.

"What's that?" asked someone.

"It's the Germans," joked another.

The Germans! In Broken Hill! Everyone laughed. They thought it was a stone pinging against the side.

The two turbaned men continued to fire at the train, ducking down after each shot to reload, or to take cover in case anyone shot back. But no one shot back. No one had any idea what was going on.

Two girls yelled "Happy New Year!" at the spectacle of two dark men in red jackets and frost-white turbans, like ice-cream almost. They imagined the shots were being fired in honour of the passing train.

A guard of honour. A stone. Children taking pot-shots at rabbits. Each truck-load formed its own interpretation. One passenger, registering the two men lying on the embankment above the trench with the water-pipe, assumed that something was wrong with the pipe – a leak? – and these men were attending to it. Another, seeing a cow on the right-hand side, wondered if some idiot was trying to shoot it. Yet another picnicker, supposing it was boys firing blanks, shouted: "Stop fooling around, or someone will get hurt!"

Then a 17-year-old dairyman's daughter, Alma Priscilla Cowie, standing beside her boyfriend, Clarence O'Brien, slumped to the floor. When Clarence reached out to hold her, he saw that the top of her head had been blown away.

The two soldiers of Allah were not Turks, but British passport-holders from India's north-west frontier.

The youngest was the ice-cream seller, Badsha Mehmed Gül, a thoughtful > 39-year-old Afridi. Born in the mountainous Tirah region, Gül had come to Australia as a cameleer. When the camel business declined, he had worked in a silver mine until the outbreak of war, and was laid off after all contracts with the German smelters were cancelled.

Then, in November, Gül had bought a horse-drawn ice-cream cart from an Italian. Already, he was a familiar figure in Argent Street. Yet Gül's friendly, open manner to Broken Hill's children, to whom he sold buttermilk ice-cream for 3d a scoop, concealed a complicated, anguished character.

Three days after the shootings, a confession was discovered, tucked under a rock and written in Dari, in which, astoundingly, Gül claimed to have visited Turkey four times – and even to have enlisted in the Sultan's army. He wished he'd still been in Turkey when war broke out, he told his companion-in-arms Molla Abdullah, apparently over a pipe of hashish in one of the humpies in the North Broken Hill camel camp, where they lived side by side.

Reserved, simple, moody, Gül's comrade Molla Abdullah was a disgruntled old cameleer with a limp. Aged 60, he had lived in Broken Hill for 15 years. Different skin colour, strange clothes, not Anglo-Saxon – boys laughed when he hobbled by and chased him down the street, throwing stones. He never retaliated, but several times complained to the police, who failed to act.

Ridiculed, Molla Abdullah immersed himself in his daily prayers. In the absence of a religious leader, he had begun to take on that role in 'Ghantown', as the North Broken Hill camel camp was known.

As well as acting as its imam, he served as the butcher of his community, killing their meat in the stipulated Muslim manner. The fact that he was not a member of the Butchers' Union in the most unionist town in the country brought him into confrontation with those who needed little excuse to treat a Pathan from north-west India as an enemy alien. The most aggressive of his persecutors was the local sanitary inspector, a short, mournful-faced Irishman called Cornelius Brosnan.

Since his arrival in Broken Hill, Molla Abdullah had slaughtered and prepared his meat in Ghantown, out of sight of the town. He had received no reprimand from the council until the moment of Brosnan's appointment.

Cornelius Brosnan was over-zealous, perhaps because he was not qualified. He had tried twice to get his certificate, and failed. Mayor Brody, though, had got to know Brosnan when he was in charge of the gang laying the wooden water-pipe from Silverton, and in 1913 appointed him Acting Chief Sanitary Inspector. Brosnan might not have a certificate, but he was a union man with "a bit of push behind him".

Brosnan set to work, and no one enjoyed his immunity. On discovering the state of the floors in the council toilets, Brosnan installed a penny-in-the-lock slot, and chastised the men and women in the council whose sense of cleanliness, he said, "did not redound to their credit".

Obsessive to prove himself in his war on scarlatina, diphtheria, pneumonia and typhoid, Brosnan became a tyrant against all filth. To keep Broken Hill's premises in conformity with the Pure Food Act's requirements, he fined a shopkeeper who sold butter which, in Brosnan's opinion, was "not fit for greasing boots". He chased a man riding in a suspicious milk cart – "the more he cried whoa! the faster he'd go," reported the Barrier Truth – and when the cart struck a stone, delayed long enough only to collect eight samples.

As well, the uncertificated ex-pipe-layer was strenuous in hunting down anyone suspected of contravening the Broken Hill Abattoirs, Markets, and Cattle Saleyards Act.

Soon after his appointment, Brosnan had received a letter from the community in Ghantown appealing in the name of religious liberty for Molla Abdullah to be able to kill their meat at their camp and not in the municipal abattoirs, where sheep and cattle were slaughtered alongside pigs ("one of the tenets of our faith is that the latter is a contamination"). On Brosnan's recommendation, the Abattoir Committee turned down the request. "We can't allow them to slaughter anywhere except at the abattoirs. There are people of 50 different religions who will want the same privileges."

Brosnan prosecuted Molla Abdullah for the first time in April 1914, for slaughtering sheep at the North Broken Hill camel camp instead of at the abattoirs. In court, the Ghantown butcher had read haltingly from a piece of paper: "Me not guilty, not know break law, very sorry, not do again." Ordered to pay a fine of £1 or go to prison for seven days, Molla Abdullah had paid the fine.

The sanitary inspector had visited Ghantown again on 4 December and found four sheepskins strung out on the fence. He looked for Molla Abdullah and beckoned him over.

In a merciless voice, Brosnan recited the regulation that each butcher's carcass slaughtered at the abattoirs must be branded with a distinctive brand in indelible red. There was no brand on these carcasses. This time, Molla Abdullah was fined £3 and ordered to pay the 6/- costs of court. The police magistrate gave Molla Abdullah until the end of December to pay, or face imprisonment for one month.

Molla Abdullah felt utterly dejected by the court case. He had no means of paying the fine. The fire that had destroyed his uninsured two-roomed house, while he was boiling some fat, had burnt all the money he had, as well as his possessions. He had lost everything. Back in Ghantown, he wallowed in an apathy from which no one could stir him, save Gül.

In his confession that he penned on the eve of the tragedy, Molla Abdullah wrote: "One day the inspector accused me. On another I begged and prayed, but he would not listen to me. I was sitting brooding in anger. Just then the man Gül Mehmed came to me and we made our grievances known to each other. I rejoiced and gladly fell in with his plans and asked God that I might die an easy death for my faith."

Gül had no need to remind Molla Abdullah that Turkey was at war with Australia, and that the Sultan, only three weeks earlier, had appealed for a jihad against the Entente Powers, obliging all Muslims young and old, on foot or mounted, to support it. Rather than go on living this persecuted and insulting existence in Broken Hill, wouldn't it be better to die gloriously with the guarantee of happiness in the next life – by killing as many Australians as they could?

Early on 1 January, 1915, the two-man army packed into the ice-chest a Snider-Enfield, which Gül had bought for £5, and a Martini-Henry breech-loader with a long steel barrel. Then they climbed on to Gül's ice-cream cart and rode out of Ghantown, following the railway line towards Silverton, to declare war on Australia.

The plan was that the engine, unmanned, would drag the 40 packed mining wagons to destruction. In the event, the jihadists missed not only the driver and fireman, but Molla Abdullah's bugbear, Cornelius Brosnan – "owing to my grudge against the inspector it was my intention to kill him first". Even so, three of their bullets killed dark-haired Alma Cowie; William Shaw, from the Sanitary Department; and Alf Millard, who had ridden up on his motorbike clutching the camera with which he intended to photograph the picnic. A fourth stray bullet later killed Jim Craig as he chopped wood in his back yard.

Once the train had steamed out of sight, the two men walked back towards town, taking shelter on a rise behind an outcrop of white quartz boulders. Here, beneath their red flag, they held out for the next two hours. They were encircled on the granite slopes below by an enraged posse that comprised, eventually, 53 troops from the 82nd Infantry Battalion, 10 policemen, members of the Volunteer Rifles – and basically "anyone with a gun who wanted to have a lash", a man in the Broken Hill library tells me, whose grandfather was on the train. This was a militia, in the words of a local reporter, "desperate in its determination to leave no work for the hangman".

I follow a road to the white rocks. Local hoons doing wheelies have left dark skid marks on the Tarmac. Heat-waves dance off the slopes. It's a desolate place, despite the presence of a ghost-white replica of what is billed, optimistically, as 'perhaps the most famous ice-cream cart in the world'.

Just before 1pm, an armed mob surged to the top of the hill. They trotted forward like wild cattle to inspect the two turbaned bodies that lay 10 yards apart. Molla Abdullah had been shot through the temple. Gül had 16 bullet wounds and was still breathing, dying moments later. From start to finish, the Battle of Broken Hill had lasted three hours, leaving six dead and seven injured, including a 23-year-old tailoress – hit by a flying fragment of bone from Alma Cowie's skull.

Weeks later, a German newspaper in Freiberg carried the following news item: "We are pleased to report the success of our arms at Broken Hill, a seaport town on the west coast of Australia. A party of troops fired on Australian troops being transported to the front by rail. The enemy lost 40 killed and 70 injured. The total loss of Turks was two dead. The capture of Broken Hill leads the way to Canberra, the strongly fortified capital of Australia."

Shortly afterwards, on a beach on the opposite side of the world, a force of 20,000 Anzacs, many with the Third Australian Brigade comprising miners from Broken Hill, landed on the Gallipoli peninsula. A lot of them would be shot through the head with bullets from the ore they had mined.

Still today, no one in Broken Hill knows where Gül Mehmed and Molla Abdullah lie buried, as if this strange and tragic event had occurred, but then had been blown away by the desert winds, until there's nothing much left or remembered.

Yet it would be a mistake to disregard their narrative, the bones of which keep reassembling, resurrected by the same combination of frustration, racial and religious discrimination, ignorance – until it reaches an intolerable pitch, and explodes.

By strange coincidence, I return to the Palace Hotel as news breaks of a manhunt in Boston for two Chechen brothers. Motivated by extremist Islamic beliefs, the young men had launched an attack on the Boston marathon, killing three and injuring 264. Their bombs: two pressure cookers.

Back in England a month later, I watch the television news. In Woolwich in south-east London, two British men of Nigerian descent have hacked a soldier to death "to avenge the killing of Muslims by British armed forces".

Then last March, at a railway station in the Chinese city of Kunming, knife-wielding men from the minority Muslim Uighur group randomly attacked a crowd, killing 29.

Last September, an Australian who goes by the name Abu Yahya ash Shami, was named military commander for the town of Jalula in northern Iraq, part of the new Islamic State, after beheading four people.

That was before the Sydney café siege and the attack on the Charlie Hebdo offices in Paris – by more marginalised individuals for whom a call to jihad resonated with a world view.

It may be a hundred years old, but the narrative played out in the Australian outback in 1915 by Badsha Mehmed Gül and Molla Abdullah touches all of us – wherever, and whoever, we are.