The creator of Peter Pan described it as his own "enchanted land."

Now the Victorian villa of Moat Brae House, in Dumfries, where JM Barrie, the creator of Neverland, played and dreamed as a youth, is to begin a new life as Scotland's national centre for children's literature.

Barrie played at Moat Brae when he was a pupil at Dumfries Academy in the 1870s, and later described his time in the town as "the happiest days of his life" and the garden where he played as a youngster “the genesis of that nefarious work – Peter Pan”.

Now £5.3 million has been raised and the house and gardens, built in 1823, is to re-open as the National Centre for Storytelling in 2018.

It is being financed by private, anonymous donations and £1.78m from the Heritage Lottery Fund, £680,000 from Creative Scotland and £500,000 from Dumfries and Galloway Council.

The Peter Pan Moat Brae Trust (PPMBT) hope the centre will attract 40,000 visitors a year and estimate it will create £1.3m for the local economy.

It will open in 2018 and will be a place to "discover children’s literature and storytelling across many eras, countries and cultures." The grounds will be retitled as a Neverland Discovery Garden.

Angus-born JM Barrie's first work of fiction was a “log book” recording the games of pirates and adventure that he played there under the name of “Sixteen String Jack”.

He enjoyed his first experiences in staged productions at Dumfries Theatre Royal.

Actress Joanna Lumley, the trust's patron, said: “This is tremendous news for Dumfries and a lovely gift to young people everywhere.

“Moat Brae inspired J M Barrie to write one of the best-loved children’s stories of all time and we hope it will give new generations of young people the courage and confidence they need to lead creative lives.

"It’s an awfully big adventure, and this is just the start.”

Dame Barbara Kelly, the trust's chair, said: “Moat Brae is a very special place and it’s wonderful that it has been saved and has a new future as a major visitor attraction and a community asset at the heart of Dumfries.

“The transformation of the house and gardens will make an invaluable contribution to the town’s social and economic regeneration. It will also provide brand new opportunities for children and families for fun and discovery."

The trust was formed in 2009 to stop the house from being demolished and a formal fundraising campaign began in 2011.

The renovated house has not been in use since 1997, will have an exhibition telling the story of Moat Brae and its links with J M Barrie.

The garden will have a pirate ship, a Wendy house, and a performance space.

Cathy Agnew, the project's development director, said: “I think J M Barrie would love to know that the town, the house and the garden which so inspired him will now inspire hundreds of thousands of others."