WASHINGTON — It's a homeowner's worst nightmare.

It's late at night and an intruder is trying to get inside your home. What do you do? How do you defend yourself?

Earlier this week, 46-year-old Alberto Espinosa was shot and killed by a homeowner in Chantilly, Va. after the homeowner claims Espinosa was trying to get inside his home.

RELATED: Wife of Chantilly man killed by Maryland homeowner says it was a 'horrible mistake'

The self-defense laws for Maryland, Virginia and D.C. vary, but each jurisdiction has some type of law in place that addresses when it's deemed legally justified to use a firearm in self-defense. 

Both Maryland and Virginia follow what's called a castle doctrine, which allows homeowners to use deadly force to protect themselves, their home and their family. However, the use of deadly force must be considered reasonable. 

RELATED: Homeowner shoots man on his Centreville property

Here's a break down of the laws in D.C., Maryland and Virginia: 

D.C.

The District does not have a law targeted specifically to a home intruder. In terms of self-defense, D.C. has a law that states a person can defend themselves when they truly believe that they're in danger of bodily harm or death. However, the law also states the person is required to take reasonable measures by stepping back or walking away. 

Section 22-40503.01 of D.C.'s law allows someone to use a firearm if it's done in legitimate self-defense. For more information on the laws, click here

Maryland

The castle doctrine in Maryland states that when a person is inside their home, they do not have to retreat. A homeowner is allowed to stand their ground and attempt to defend themselves against an intruder, as long as the use of force is reasonable.  

Maryland also has a duty to retreat law that states if a person is defending themselves outside of their home, they have a duty to retreat. For more information on the laws, click here

Virginia

Virginia law defines a justifiable act of self-defense as when the person acting in self-defense did not provoke the attack. An excusable self-defense is defined in the law as a situation when a person provoked the attack, but tried to retreat from the attack before using deadly force in self-defense. 

Section 18.2-282 of Virginia law also states that it is unlawful to display a firearm in attempts to scare another person unless a person is engaged in a justifiable or excusable self-defense situation. For more information on the laws, click here.

Download the brand new WUSA9 app here.

Sign up for the Get Up DC newsletter: Your forecast. Your commute. Your news.