The shootout happened around 11:00 p.m. at the Hess station located at the intersection of 5th Street and Lehigh Avenue in the West Kensington section of the city.
Officers ordered the 19-year-old man to drop his gun, but police say he kept firing. So officers opened fire on the man, hitting him twice.
The gunman died at the hospital overnight.
He has not yet been identified.
Police say the man was firing at point blank range, and could have easily killed the other man or one of the officers.
Police took the second man in for questioning.