Peter Pearce, director of the Landmark Trust, said: “For more than 20 years we have been fighting to rescue this extraordinary castle from a derelict state and imminent total loss to the nation.

Thanks to the support from thousands of people for our appeal, we have at last secured the funds to achieve this objective, giving everyone the opportunity to stay in and visit this most atmospheric of places once work is complete.”

Heritage funding two years ago enabled emergency repairs and consolidation work to be carried out on the castle, which was once home to three queens of England, became a hotel in the late 60s and was destroyed by fire in 1978.

The main phase of the project will be led by a design team from London-based architects Witherford Watson Mann, to create two storey accommodation in the oldest part of the castle.

It will include a large living room with kitchen, dining and sitting areas and four bedrooms and two bathrooms, plus an impressive entrance hall. The front part of the castle will be partially roofed to create an outer court.

Although the funds now raised will pay for the castle’s restoration, further donations are still being sought to allow additional work to be done to its wider setting.

This includes repairs to the curtain walls and moat, the 18th century Gothic stable block and care of the historic parkland surrounding the moated site, much of which is a listed Scheduled Monument.