A section of roof at the National Library of Wales in Aberystwyth has been destroyed by fire.
Flames and smoke were seen coming from the roof at the rear and up to 300 staff and 100 visitors were evacuated from the building.
More than 30 firefighters attended, and it was confirmed by 18:30 BST on Friday that the blaze was out, just under four hours after it was reported.
Library staff said it was not known how it began, but everyone was safe.
Arwel Jones, director of public services at the library, said workers had been on the roof near to where the fire started, but it was impossible to say at the moment whether that was linked to the incident.
The alarm was raised at 14:40 BST. Reports from the scene suggested a 100ft (30m) section of the roof was destroyed.
An investigation into the cause of the blaze is due to start on Saturday, and Mid and West Wales Fire and Rescue Service said it was working closely with library staff to protect the "many national treasures" held there.
The affected area is largely used as office space and for new acquisitions, but it is not thought that any books have been damaged. The library will be closed on Saturday.
Aled Gruffydd Jones, who takes over as head librarian in August, told the BBC Wales News website: "Everybody is out and safe and all the procedures have been followed.
"We need to know what happened and how. I'm puzzled by how it could have started. Clearly we need an inquiry."
Eleven fire appliances went to the scene. Some firefighters used an aerial ladder while others used breathing apparatus went into the building.
Smoke could be seen coming from a part of the library called Building 2, and a mobile command unit was set up to co-ordinate the incident.
The Aberystwyth University sports centre, which is next door to the library, was closed as a precaution.
Elwyn Williams, head of promotions at the library, said: "We were in a meeting when at 2.40pm when the library's fire alarm went off.
"We followed all our procedures and got staff and visitors out of the building - that went smoothly. Then the emergency services arrived and we closed the road leading to the library.
"But we're shutting the library tomorrow due to the incident. It's impossible to know what the cause is at the moment."
William Powell, Liberal Democrat AM for Mid and West Wales, said: "The library is the home to Wales' precious cultural heritage and any damage or loss of any of the collections housed at the library would be a huge blow.
"We all owe a great deal to the firefighters of the Mid and West Wales Fire Service and I pray that they have been successful in containing the blaze without sustaining injury to themselves," Mr Powell added.
The mayor of Aberystwyth, Dylan Lewis, said: "I could see smoke rising above the building and soon afterwards you could hear the sirens from various different fire appliances making their way up there."
"It's a very imposing building - anyone who has ever been to the town will tell you. It looks directly down onto the town and down across the whole of Cardigan Bay.
"It is not just important to the academic life of the town, it is important to the cultural life of the whole of Wales."
Jamie Barker from the neighbouring university students' union said they watched as smoke and flames billowed from the roof.
"We were all in our offices when we could smell the smoke coming up the hill," he said.
"It was very quick. We headed outside, there was quite a crowd gathering on our concourse which overlooks more of the National Library, and that's where we could see the flames billowing up."