St Andrews Voices has not even had its second birthday yet, but already the ambitious Fife festival is staging an opera.

True, it is only half-an-hour and involves a cast of three, but it is a Scottish premiere of a new work by one of Scotland's leading composers, and it has the makings of a compelling, challenging drama.

The opera is Hagar In The Wilderness: words by Clara Glynn, music by Sally Beamish. It was written as a companion piece for Curlew River, one of Benjamin Britten's church parables. The subject matter is similarly religious: it is the Old Testament tale of Abraham's servant Hagar, who carries Abraham's child because he thinks his wife Sarah is too old to conceive, then is cast out when Sarah miraculously becomes pregnant.

Beamish is quick to emphasise the story's universal and contemporary resonances. "It is about the displacement of people, the dispossessed," she says. "The story is in both the Bible and the Koran. It is also about being a mother: Hagar can't bare to watch her child die and so walks away instead - I think that cruel dilemma really spoke to Clara."

The libretto came first, as it often does, and when Glynn handed Beamish a draft the music sprang up fast. She was supposed to be on holiday in the south of France, but spent the week composing. Beamish says she wanted to work with Glynn because "she's really direct, which is important in opera. Her language is always clear, and she is used to working on screenplays and radio dramas so she has a real sense of how dramatic trajectory works in short spans."

She says the libretto tells the story simply. "Sometimes it is quite startling in its starkness. It is very raw. Even though the language is very direct, it is also very lyrical and poetic." She quotes a line: "'The world was knocked off course by his fat little fist.' The idea of this baby's fist knocking the whole of Abraham's life off course - it's beautifully put."

The relationship between Hagar and Abraham is an essential part of the opera; the moment when he asks her to leave is the crux. "After that there becomes a very bitter sense of unfairness: she says, 'Children are dying everywhere, so why am I surprised God does nothing?'" Occasionally Glynn quotes directly from the Bible, such as the line, "there's a time and a season for everything". But mostly, says Beamish, "the language and the setting language are very now".

I ask how much Britten's soundworld was in her mind when she was composing the opera. She has taken on some of the orchestration from Curlew River (flute, harp, viola, bass, percussion) but says that if anything she was more informed by certain French repertoire for flute, harp and viola. "I have been working a lot with Debussy recently - I have just made an arrangement of La Mer for piano trio - so I was conscious of creating French lines without much to play with. Plus I was in the south of France when I was writing it, so maybe that crept in too ..."

In general she describes the score as clear, open and spare, and says she has left plenty of space for the vocal lines to come out. "So often you come out of a new opera and you are not quite sure what it is about, but you do not want to ask because you think it must be you. I was keen to avoid that. It is important in opera that the audience really wants to know what happens next. "

Generally, Beamish is as busy as ever, churning out high-profile commissions at a rate of knots. Flodden, a 25-minute work for the Scottish Chamber Orchestra that marked the 500th anniversary of the battle, was premiered last month. She is writing a ballet for Birmingham Royal Ballet, and a full oratorio (orchestra, choir and soloists) with a text by Andrew Motion that premieres at the Barbican in November next year to commemorate the First World War centenary. "I keep being asked to do pieces about war," she says. "I'm a Quaker; it's a bit strange!"

Or perhaps it's not so strange. Just as Britten, a pacifist, was commissioned to write music for the opening of Coventry Cathedral (he produced the troubled War Requiem), Beamish has a capacity to communicate her convictions with devastating directness. There is blazing pathos in Flodden, and it sounds as though there is deep compassion in her retelling of Hagar's story.

St Andrews Voices runs Thursday-Sunday; Hagar In The Wilderness is on Friday. The Scottish Chamber Orchestra perform Flodden in Edinburgh on October 24 and Glasgow on October 25.