For landline phones the telephone company has their own emergency backup power in case the commercial power goes out. This backup power is a combination of batteries and diesel generator at the central office, or just batteries for lines that run through multiplexers in the field. For landlines the power to operate your phone comes through the wires from the TelCo into your handset. Obviously if you have a telephone that requires its own source of electricity (like a cordless phone) it will not work in a power outage. You are right in that in case of extended outages landlines are probably more reliable than cell phones or VoIP (i.e, phones that run through your cable TV line).
Here is an article on how phones work:
Howstuffworks "How Telephones Work"