After spending close to a decade finishing her first novel, Jessica Townsend, 31, had grown very comfortable with her morning routine of “writing on my laptop in my pajamas with a cup of tea.”

But that pattern was happily and thoroughly upended last October when her agent pitched the novel, Nevermoor: The Trials of Morrigan Crow, at the Frankfurt Book Fair. In an eight-house auction, the Hachette Book Group won English-language rights to publish the trilogy in the U.S., the U.K., and Australia. Subsequently, rights have sold in 25 additional territories. “Every 5 a.m. for about a month there was a flurry of e-mails. Bizarre good news after bizarre good news,” Townsend said. “I still don’t know how to take it in.”

Film rights have also been sold to 20th Century Fox. “I just loved their team,” Townsend said. “They loved the book and they had thoughts about how to make it into a film that made me realize that they had thought very deeply about it.”

The book, which has drawn comparisons to Harry Potter, is about a cursed child named Morrigan who is born on Eventide, the unluckiest day of the year, destined to die on her 11th birthday until she is whisked away by a strange man to Nevermoor, a fantasy version of London. The problem is that Morrigan can only remain in Nevermoor – and escape death – if she earns a place in the city’s most prestigious organization, the Wondrous Society, by passing four difficult and dangerous tests.

The book will publish on October 31, and in the U.K. in November. The six-figure, three-book deal was brokered by Gemma Cooper at the Bent Agency. The manuscript was first championed at Little, Brown by an assistant editor, Kheryn Callendar, who will co-edit the U.S. edition with Little, Brown editor-in-chief, Alvina Ling.

"I’m extremely selective about the new authors I acquire for our list – but as soon as I read this manuscript, I knew I had to have it,” said Ling. “It’s smart, funny, unique, imaginative, surprising, and action-packed. It’s the best thing I’ve read on submission in a long, long time.”

Townsend, who lives in Queensland, on Australia’s northeastern coast, first got the idea for her main character when she was 18. But she didn’t take up writing Morrigan’s story in earnest until she was 22. Progress was slow.

“I know some magical writers can produce a draft in six months and, bless them, that’s amazing,” she said. “But the final product is really a result of that long incubation. Book one is like the tip of the iceberg. I know everything about this world because I spent a lot of time plotting it out instead of actually finishing a draft. Maybe there’s a case to be made for procrastination. I should tell my high school teachers that.”

Her first reader was her sister, Sally, with whom she worked for several years at Australia Zoo, a children’s wildlife magazine founded by the late “Crocodile Hunter” Steve Irwin.

“She was pestering me for ages to let her read it,” Townsend said. “And I didn’t really write the book with any other audience in mind except me and her. Anytime I wrote something that made me laugh, I thought, ‘Sally’s going to laugh at this, too.’ ”

Like many young Australians, Townsend spent several years in her 20s in Europe. But instead of backpacking her way across the continent, she landed in London, fell in love with the city and decided to stay put, finding work as a copyeditor. While she was writing the book, she was already dreaming of signing with a London literary agency, “so I could go back and forth.” She spent a year or two researching agents. “I’m a bit of a nerd so I had a spreadsheet and all that–first tier, second tier, etc.,” she said.

Within a month of sending out queries, she had four offers for representation and signed with Cooper. “The day we spoke she was moving to Chicago, so there went the London agent,” Townsend said. “But she’s made all this happen. It is amazing that you can put the product of your blood, sweat, and tears into a pair of hands you trust and sit back and relax while Gemma does all the work.”

Little, Brown will do a pre-pub launch for Nevermoor next month and plans to bring Townsend to Children’s Institute to meet with booksellers and sign galleys. Meanwhile, Townsend is home in Australia, writing in the mornings in her pajamas, with a cup of tea. “I don’t feel like my life has changed,” she said. Though the series was sold as a trilogy, Townsend has plots for about nine books. Procrastination is now a thing of the past – book two is well underway. “Please write that I’m perfectly confident I can complete this book on time,” she said. “I don’t want my editors to have coronary episodes reading this.”

Nevermoor: The Trials of Morrigan Crow by Jessica Townsend. Little, Brown, $17.99 Oct. 31 ISBN 978-0-31650-888-9