If someone has invaded your home, and you fear great bodily harm or death, then yes -- the law will generally protect you if you shoot an intruder. Outside of those very specific circumstances, however, the question is a bit too complicated to provide a black and white answer, especially when you consider the different laws relating to self-defense among the states.
The law gives everyone the right to defend themselves with a reasonable response. Self-defense is an affirmative defense to a charged violent crime. This means that if someone is charged with murder, or assault, they can use self-defense as a legal excuse for the conduct if they can prove it in a court of law. For self-defense to apply, a defendant will generally need to show the existence of an immediate threat.
In addition, any force used against an intruder must usually be proportionate to harm that is reasonably perceived. For example, if a burglar were to enter your bedroom with a yellow banana as a weapon, you would probably not be justified in shooting him or her with a 20 gauge shotgun. However, if the burglar were carrying a fake pistol, and you reasonably believed it to be real, you would likely be justified in shooting the intruder.
If you act with a disproportionate response, or believe that banana to be a futuristic space weapon (an unreasonable perception), this becomes what is referred to as imperfect self-defense. This can mitigate the crime you are charged with and usually result in a lesser punishment, although it will not completely excuse the disproportionate response or result in an acquittal at trial.
Duty to Retreat or Stand Your Ground?
In many states, there is a duty to retreat to safety, if possible, before using force. However, in many other states, there are "stand your ground" laws that remove the duty to retreat and allow a person to claim self-defense, even if they made no attempt to flee. However, even in "stand your ground" states there is no license to attack without cause, and the rules vary on the ability to use lethal force.
Again, in some states, a person is privileged to use deadly force against anyone who unlawfully enters their home. In these states, there is no need to take the time to assess the intruder's ability to use deadly or nonlethal force. However, the specifics and applicability vary state to state. If you are uncertain about your state's rule, it may be advisable to consult with an attorney to learn more.
Getting Legal Help with Your Self-Defense Argument
Self-defense is a powerful argument in the criminal justice system and, if supported by the evidence, can result in a complete acquittal. However, self-defense is not always clear-cut, even in cases of home invasion, and self-defense laws vary from state to state. If you're facing criminal charges and you believe you acted in self-defense, it's in your best interest to speak with an experienced criminal defense attorney to discuss your specific situation.