If Abi Morgan hadn't met a couple of nuns on train, her new play for the National Theatre of Scotland might not have happened.

The writer of celebrated TV drama The Hour and the forthcoming Margaret Thatcher biopic, The Iron Lady, starring Meryl Streep, was travelling up to the Edinburgh Festival, and fell into conversation with the pair sitting opposite her.

“They were quite elderly,” Morgan remembers, “and were very sweet and very inspiring. But during the course of the journey it became apparent that they were being left behind, and that there were no new young women coming up in their order. Suddenly they were looking beneath them at this society they’d lived in all their adult lives, and there was no new blood. These women’s lives can be traced and mapped out. They don’t have children, they don’t smoke, they’ve never married, and there’s something anthropological going on there about a way of life which is maybe going to die out in the 21st century.”

Around the same time, Morgan was reading Ageing With Grace, a study of almost 700 Catholic sisters aged between 74 and 106 by Alzheimer’s Disease expert Dr David Snowdon. “It’s a beautifully written book, and I saw the parallels of two inherent forms of belief that exist in the world of a scientist and the world of nuns,” she says. “Science is a belief in something that can be proven to exist, and religion is a belief in something that cannot be proven. So I had this idea of imagining a very different type of scientist and a notion of a study group under pressure. For the doctor, if something doesn’t exist then it doesn’t exist. He comes into contact with Ursula, this Mother Superior who fell in love with art and literature, and who has to believe in a God that she can’t see, and who she can’t always understand. These are two very intelligent people with two very different kinds of faith.”

The result of all this is 27, which opens at Edinburgh’s Royal Lyceum Theatre this coming weekend in a production directed by NTS artistic director Vicky Featherstone. This will be a professional reunion of two artists who first worked together a decade ago when Featherstone was in charge of new writing company, Paines Plough. The pair worked on two plays by Morgan which were produced within a year of each other, and which both toured to Edinburgh’s Traverse Theatre.

The first, Splendour, was a relatively conventional study of four women waiting for civil war while ensconced in a private residence in an east European state. The second, Tiny Dynamite, was a collaboration between Paines Plough and the more physically inclined Frantic Assembly, who recently co-produced the high-octane boxing epic, Beautiful Burnout, with the NTS.

“I was really lucky to meet Vicky,” Morgan says. “There’s been a series of really inspiring women who have been incredibly supportive of my work. There were all these women coming into positions of power who’ve championed me. After Vicky said she was interested in 27, its been really interesting watch it evolve from very early workshops. It’s been like watching this ugly baby grow into a swan.”

Somewhere between these two stints with Featherstone alongside several other stage plays, Morgan became a writer of serious television drama. She first made her mark in 2004 with Sex Traffic, a two-part drama which won eight Baftas. She followed this two years later with a BBC/HBO mini-series, Tsunami: The Aftermath, which won a slew of Bafta, Emmy and Golden Globe awards. In 2007 Morgan co-wrote (with Laura Jones) an adaptation of Monica Ali’s novel, Brick Lane, which won a best screenplay award at the Dinard Festival of British Cinema. In the 2010 TV film Royal Wedding, Morgan looked at family life in the Thatcher’s Britain of 1981 set against the back-drop of a street party to celebrate the wedding of Prince Charles and Lady Diana Spencer.

All of her film and television work looks at the human stories behind a recognisable historical social or political fabric. This was even more pronounced in The Hour, the glossily-stylised BBC drama set among fictional BBC radio types in the run up to the 1956 Suez crisis. The Iron Lady, too, looks set to be a talking point. “I tend to write about big political events, but through very personal eyes. The Iron Lady is about power, but it’s also about a very personal view of politics.”

The daughter of actress Pat England and theatre director Gareth Morgan, she was 11 when Mrs Thatcher was elected. Growing up and coming of age during the Conservative Prime Minister’s three terms in office may go some way to explaining Morgan’s all-too-human concerns in her work.

“It’s interesting that I’ve come back to theatre, because I find writing plays really hard, which I think is something to do with the intensity of focus. With TV and film the director is the author, and you don’t own the work in the same way as theatre, where the playwright is much more central.”

It doesn’t take too much thought to recognise other parallels in Morgan’s description of 27 with the creative process itself. As a writer and an artist, she too must square up to the dichotomy between an abstract idea and a blank screen on a daily basis, and some kind of leap of faith must be required to marry the two.

“I suppose there are parallels between a writer and a nun,” Morgan concedes. “They’re both involved in a silent course of study, trying to make order out of chaos. There’s an isolation required to both as well, and there’s a spiritual side to that, so you could call it a leap of faith.”

With two stage plays up and running and The Iron Lady pending, there is plenty more of Morgan’s work to come. A TV adaptation of Sebastian Faulks’s First World War novel, Birdsong, is in post-production, while Shame, a collaboration with Turner Prize winning artist and director of Hunger, Steve McQueen, due to be released in January, has already picked up five awards at this year’s Venice Film Festival.

Morgan is currently writing the second series of The Hour and there are “a couple of films” on the go.

“I just keep my head down and keep on writing,” she says. “Writing is how I keep myself stable and sane, and it’s definitely my compulsion. But I’m looking forward to having some time where I can just look out of the window and observe. There’s a desire there – I have to connect with the world beyond that window. I’ll go very quiet after all this and you’ll never hear from me again.”

27, Royal Lyceum Theatre, Edinburgh, October 21-November 12, www.lyceum.org.uk www.nationaltheatrescotland.com