HARRISBURG - In Pennsylvania, as in most states, your home is your castle and you have a right to defend it.

Soon, you will be able to add your car. Or the sidewalk. Or anywhere you "have the legal right to be."

The state Senate, in a 45-5 vote, gave final approval Monday to the so-called castle doctrine bill to expand the right of people to use deadly force against attackers in places outside their homes.

A spokesman for Gov. Corbett said the governor would sign the bill but was not sure when.

The legislation, sponsored by Rep. Scott Perry (R., York), eliminates a requirement that people try to retreat before using deadly force in those situations.

Proponents - led by the National Rifle Association - say the legislation would enhance public safety by exempting gun owners acting in self-defense from prosecution.

"Law-abiding gun owners should not have to fear prosecution for acting to prevent a violent crime," said Sen. Richard Alloway (R., Franklin). "I am thankful that the General Assembly has taken action to protect responsible gun owners who respond when facing a serious threat from a criminal."

Opponents, including a number of police chiefs and mayors, argue that existing laws provide adequate safeguards and warn the bill could foster a "Wild West" mentality.

"This is going to be dangerous for Pennsylvanians," said Max Nacheman, executive director of CeaseFirePA, a gun-control group. "This creates more situations in which violence is an alternative."

Pennsylvania law, like that of New Jersey and most other states, already establishes that a person has a right to defend himself in his home.

In at least two dozen states, however, the law goes further, removing a person's "duty to retreat" - say, to rush inside and bolt the door - before using deadly force.

Gov. Ed Rendell vetoed a similar measure last year, saying it would escalate violence.

The Pennsylvania District Attorneys Association had opposed the bill, but dropped its opposition after it was amended to make it harder to use as a defense for criminal activity.

One Philadelphia-area prosecutor called the bill "a solution in search of a problem" and said he feared the law could still make it more difficult to prosecute criminals.

"We'll probably not be caused much difficulty by it in Bucks County," said Bucks County District Attorney David Heckler. "But I think in an urban environment, where there are lots of people carrying firearms on the street, it may well mean that some people who should be convicted of murder end up walking."

Said Philadelphia District Attorney Seth Williams: "Though this law is not necessary because current law respects and protects those lawfully exercising their right to self-defense, if there must be a new law expanding the castle doctrine, this legislation contains the best language possible."

Contact staff writer Amy Worden at 717-783-2584 or aworden@phillynews.com.

Inquirer staff writer Larry King contributed to this article.