The fire around midnight gutted a dormitory and school building where students slept about 7 miles (11 kilometers) east of Monrovia, police spokesman Moses Carter said. Only the imam and two students escaped, he said. The cause of the fire was under investigation.
Hundreds of grief-stricken people stood in shock as ambulances took away the bodies. Others wailed and wept as police pushed back a curious, surging crowd.
The president of the West African nation, George Weah, visited the scene and was set to attend the victims' funeral at a Monrovia mosque before burial later in the day, said spokesman Isaac Solo Kelgbeh.
Pastor Emmanuel Herbert of a nearby church, Fire World Pentecostal Assembly, told The Associated Press that he and his congregation woke up to sounds of the fire and called for help.
"When I turned around to look, the entire place was red. When I looked through the window, I saw the whole place blazing with fire," he said.
The fire was so strong there was no way to enter the buildings, the pastor said.
Follow Africa news at https://twitter.com/AP_Africa
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.