A firewall is used to protect a networked server from damage by those who log in to it. This can either be a computer equipped with security features, software protection (called defensive coding), or both. A firewall allows only certain messages from the Internet to flow in and out of the internal network. So, basically, it's a lot like a wall of fire. Whatever.
Note: What many homeusers call a FireWall is actually just an IDS (IntrusionDetectionSystem) or a so called "Personal Firewall".
A real firewall is a piece of hardware independent of the system that is to be protected.