No, firewalls will not keep you secure IF you open ports. To applications listening on those ports it's as though the firewall isn't even there. It's important to enable OUTGOING filtering as well, to only allow the ports from YOUR apps to access the Internet.
Assuming the attacker has rooted your system he will try to open additional listening ports to login externally to your computer. The firewall may help in this case, BUT the hacker still has access to your system to use as they want.
Now the answer to your original question:
Ports provide a *potential* path for an intruder to gain access to your systems.
I say *potential* because the outcome is greatly dependent on:
a)The skill of the attacker
b)The specific service active on that port
c)The hardening of the listening system
d)Other security devices such as IDS (Intrusion Detection System) monitoring the connection.
One of the first things an attacker will do is to try identify the OS of the system. That's pretty easy using TCP fingerprinting.
Next she'll try to determine the service running on the port
If you are following standard port numbering that job is done.
So try to use non-standard high numbered ports instead.
Next he will try every exploit and buffer overflow attack on record.
The only way to protect against this is to keep your OS up to date with patches.
So in general, if you don't absolutely positively need to have incoming connections from the Internet, keep everything closed.
In apps where you think you need incoming connections you can often use a proxy server as a way to bridge clients to another server. But that depends on the application.