Many of San Francisco's first firehouses are gone, coincidentally burned in fires.

Built around the turn of the century to store horse-drawn equipment and the first steam-powered engines, about two dozen firehouses remain as architectural jewel boxes tucked into the city's neighborhoods.

Some are still owned by the fire department, but many of these city treasures were sold over the years and now serve a variety of other purposes.

One is a neighborhood dive bar and another a children's school. Several house businesses, including an architecture studio and a marketing firm. Many are now private homes. One in Pacific Heights has a disco ball in its front room, and one in Noe Valley sold for $5.3 million two years ago.

The oldest survivor is a brick firehouse with iron-cast detail at 1458 Valencia St. Engine Company No. 13 was built in 1883, and when the San Francisco Fire Department sold the building at a surplus auction, it became a private home in 1958.

In the gallery above, you’ll find the city’s 25 oldest firehouses, with several dating back before the 1906 earthquake. For each, you'll find details on the firehouse's modern-day use as well as a little bit of history provided by the Guardians of the City, an organization celebrating the history of the city’s fire responders.

San Francisco has a small footprint of only 49 square miles, but its hilly geography, gusty weather and dense housing make fighting fires challenging. Firehouses have long been abundant to provide protection.

“I’m not 100 percent sure, but I think we have the most surviving retired firehouses in their original form,” said Paul Barry, a retired S.F. firefighter and director of the Guardians of the City.

San Francisco's fire history goes back to the Gold Rush era, when the city swelled with hopeful prospectors in search of their fortunes. A town that was only 200 residents in 1846 grew to 36,000 people by 1852 and 150,000 by 1857, becoming the largest and most important financial center in the American West.

Volunteer companies popped up to protect a highly flammable city of mostly wood buildings and canvas, but it wasn’t enough to stop the devastating fire of 1849 that started on Christmas Eve and destroyed a third of the city. The devastating inferno led the Town Council to pass an ordinance to organize the city’s Fire Department of volunteers. A paid department was established in 1966.

Today, the city operates about 50 stations, a few of which are housed in vintage firehouses.

Amy Graff is a digital editor with SFGATE. Email her at agraff@sfgate.com.