As anti-aircraft fire crackled in the grey skies above Hill Top Farm, north of Ypres, Belgium, on Sunday, December, 16, 1917, Fred Farrell hurriedly sketched the bleak, ravaged landscape in front of him.

Some distance away, a group of figures moved slowly in procession. They were all that remained of the 17th Highland Light Infantry officers following the failed attack on Passchendaele Ridge a few nights earlier.

The operation failed to gain any ground and all three battalions involved suffered heavy losses. The ground had been covered with snow, the night was moonlit and the Germans knew an attack was coming. All too visible, the soldiers were cut down by machine gun and artillery fire. Farrell's sketch shows the surviving soldiers gathered around a makeshift altar, their heads bowed as the chaplain leads a service.

A well-known artist of his time, Farrell's legacy has been consigned to the occasional footnote in military history books. His work has not been exhibited since 1920 and large parts of his life remain a mystery to historians, but Farrell risked his life to give the people of his home city an insight into the efforts of their men on the front line.

"In 1920, some of his works were displayed in Glasgow City Chambers, but his work has been overlooked, which is surprising because he is quite a unique character," says Jo Meacock, curator of British Art 1600-1960, at Glasgow Museums. "He was the only official war artist commissioned by a city rather than by the government or the war museum or armed forces."

A century later, experts including Meacock have been working to bring his paintings to exhibition and have been searching the city's archives and records to find out more about this enigmatic man.

"He is almost anonymous," says Alan Greenlees, who has project managed the exhibition. "He trained as a civil engineer. His brother was also a civil engineer and Farrell was apprentice to him for a while in Dunoon. However, we haven't found any evidence that he became a chartered civil engineer so we don't know where he went with that. He started as an amateur artist and then he developed a reputation as an etcher and a water-colourist."

Despite his relatively high profile at the time, only one photograph has been found of Farrell, from a local newspaper, The Bulletin. Post Office directories list his father and his brother but, bizarrely, not Farrell himself, although he does appear in the censuses of 1891 and 1901, along with the rest of his family, at a house in Glassford Street, Glasgow. Records also reveal a marriage in 1911 and a move to Uddingston in the same year but other biographical details and evidence of how he made his living are scant.

What is known is that Farrell's experience of war was not always as an observer. Records show that, having signed up at the end of 1915, he was enlisted in June 1916. However, the details of his role are baffling. "Farrell went out as a sapper, which is an engineer involved with trench digging and bridge building, infrastructure stuff," says Greenlees. "However, if he was a chartered civil engineer he would have gone in as an officer, which he didn't. Because he has this technical background, and this is where the supposition comes in, was he doing some kind of technical drawing? There are lots of unknowns."

Whatever his role, Farrell's active service was to be cut short. Within six months he was discharged on the grounds of ill health after developing a gastric ulcer. Knowing this would rule him out of being sent back to the front line for at least 12 months, he was keen to find a way back sooner.

Meacock found letters from Farrell to Glasgow's Lord Provost, Sir Thomas Dunlop, and the War Office seeking permission to go to the front as a war artist. "He seems to have had a real civic conscience," says Meacock. "Reading the diaries of other war artists, they talk about going back to the front and being shelled, or at least being very near shelling, it was very disconcerting. To choose to go back into that environment, it does say something about him as a man. You get the idea that some artists chose to become official war artists perhaps to get out of active service, but Farrell is wanting to go after he has been discharged."

The researchers scoured the archives to piece together snippets from the Lord Provost's records and from Corporation of Glasgow minutes to get more information about his commission. Farrell appears to have come from an influential Glasgow family and his father was the curator at the Trades House in Glassford Street.

As part of his unusual commission, Farrell spent three weeks in Flanders, Belgium, in November 1917, where he drew three battalions of the Highland Light Infantry. In late 1918 he spent two months in France where he drew several units of the 51st (Highland) Division, which had the regiments the Black Watch, Seaforth Highlanders, Gordon Highlanders and the Argyll and Sutherland Highlanders. Despite the Highland designation, many of the men serving in the 51st were from Glasgow. In some of his paintings individual soldiers are named, which would have been of great interest to families back home.

The finances involved in these trips, in terms of travel and materials, would have been significant. A letter from Farrell to Glasgow Corporation reveals he seemed financially comfortable, despite the fact researchers have been unable to establish how he made his living. In it, he says he has spent another £100 on materials, which he is happy to shoulder, but wonders if the council could possibly reimburse him.

There are no diaries to tell us what Farrell thought or what his experiences were, but he seems to have had access to the soldiers.

Mark Roberts, community heritage manager at Glasgow Museums, focused on the military history. "When Farrell went to the front he managed to get all the soldiers to stand around and pose for him, at the scene or nearby, and I don't think anyone else got people to do that. He must have had quite a lot of clout with the regiments and divisions, which is quite unusual."

Certainly, Farrell had an insight into life on the front line and so was perhaps more aware of army protocol than some official war artists. Farrell's reputation as an etcher and ability to make a quick sketch would have made him a more favoured choice than some artists, who would look for generals to sit and pose for an oil painting.

As the nature of war itself changed, so did the way artists had to approach it. The image of the glorious victory on the battlefield no longer rang true. From an artistic point of view, the vast open landscapes, and the fact that most of the men would be out of view, presented a huge challenge. "You take the people away and what you've got is grey, brown cratered ground, trees stumps, endless Flanders horizons, grey sky," says Greenlees. "It's just nothingness, you wouldn't know there was a huge war going on there."

"It's not Lady Butler's charging Scots Greys at Waterloo, these are real pictures, made at the place, at the time to record what it was like" adds Roberts. "It's not men in red coats, waving flags, blowing trumpets on a neat battlefield with people dying, in a gentile manner, to one side."

Farrell's style varies widely. Some of the paintings show his scribbled notes of details which he was unable to capture at the time but wanted to add later. While some of the paintings were made in the moment, others were reconstructions of events which had happened a few days earlier. In fact, some of the pictures of the 51st which were done in this way have a distinctive, almost cartoonish style with men posing on the battlefield as in a scene from Boys' Own magazine. Others are more stark, atmospheric depictions, such as the one which shows the graves at Passchendaele.

"It was felt this was creating an important record and recording real soldiers who many people would be connected to in Glasgow. It was felt it would have real significance for Glasgow, so it's unique as a record for the city," says Meacock.

Glasgow Corporation selected 50 of the 99 paintings. "It's interesting the pieces which Glasgow chose, because they are not the propaganda pieces you might think. One of the more reflective pieces, which is quite disturbing and macabre, is of a dead soldier caught in barbed wire. I don't know how it got through censorship. It suggests another side to Farrell, that he is questioning the war and wants to convey the reality of it. Even in the landscapes, there are gruesome reminders, graves, things that remind you of the sacrifices and are not glorifying it."

Farrell also captured the war effort at home. His commission included paintings inside some of the city's many munitions factories which chart the seismic change in attitudes to working women. Fiona Hayes, curator of social history, says: "It's fantastic that we have the selection of paintings actually showing them working. You get a sense of what it was like to be there."

The detailed nature of these paintings suggests Farrell spent a significant amount of time in the factories. His engineering background comes through in the detail of the machinery and building structure. The Glasgow munitions factories were being held up as templates for good practice and their visitor books reveal a list of dignitaries coming from across Britain.

A painting of a Parkhead factory shows a melting shop where the men are doing the skilled work and the women are lugging the ingots of metal. "The women came in initially as dilutees, that was the term. They actually broke up the skilled labour posts and said women can do this part and the men can do the proper skilled bit," explains Hayes. "As the war progresses, however, an awful lot of women, particularly in Glasgow, are coming in and doing the skilled work."

A painting of the projectile factory at Cardonald, occupied today by Howden Compressors, emphasises the hard, physical nature of the women's work. In her research, Hayes came across a souvenir brochure on the factory. "You get this idea of this huge machine churning out all these shells and bringing in all these thousands of women."

The work was hard, dirty and dangerous, but there was some welfare provision for the employees and the Glasgow factories were often at the forefront of addressing how welfare issues could increase productivity.

These portrayals of women in the factories, and the men on the front, were exhibited in Glasgow in 1920. Since then, Farrell's art work has never been seen in public. An accompanying book will be published later this year which includes essays by the experts involved in the exhibition, alongside all 50 of the works reproduced.

Curators hope the exhibition will encourage members of the public to fill in the stories of the men who are captured in Farrell's paintings, or indeed, cast light on the life of this most mysterious of men whose determination to record the reality of Glasgow's war created this unique slice of social and military history.