SP is taking that gun to give P so that he is armed. SP knows that his son Yash has outstanding physical powers and can beat anybody in hand to hand combat. Therefore he wants to make sure that P has the advantage when Yash confronts him.
P holds that gun against Ansh in exchange for Aarti. Otherwise Aarti would never be in P's clutches. We saw P taking her to the hospital for the baby to be aborted.