It happened just after 7:30 p.m. Tuesday on the 2600 block of South 9th Street.
Officers responding to the scene found the teen inside an upstairs bedroom.
Police say the teen was visiting a 16-year-old who lives at the home.
At some point, police say the two teens gained access to gun owned by an adult who also lives the house.
The weapon discharged, hitting the teen in the stomach.
The victim was rushed to Jefferson Hospital in critical condition. He is expected to survive.
Police believe the shooting was accidental, but have not determined exactly how it happened.
"We do believe it's an accidental shooting, however, we don't know if it's a accidentally self-inflicted, or someone who is inside of the property handling the gun accidentally shot this 17-year-old," said Philadelphia Chief Inspector Scott Small.
Officials say they're getting limited cooperation from teens and adults inside the home.
"We're not getting full cooperation from other teenagers and even other adults inside the property," Small said.
Investigators say they are holding everyone inside the home as they continue to investigate and try to figure out what happened.
So far, no charges have been filed and no arrests have been made.
The investigation remains ongoing.