It can depend on the level of ball and their rules. Let's start with to what organization are you referring?
National Federation of High Schools (from a three year old rule book) ....
Provision 1: If a relief pitcher meets all of the following conditions, the official scorer shall credit that pitcher with a save:
a) The relief pitcher is the finishing pitcher in a game won by the relief pitcher's team,
b) The relief pitcher is not credited with the win, and
c) The relief pitcher meets one of the following conditions by:
1) entering the game with a lead of not more than three runs and pitches at least one inning,
2) entering the game with the potential tying run on base, at bat, or on deck, or
3) pitching effectively for at least three innings.
Note: No more than one save may be credited in each game.