Normally the rule is the starting pitcher gets the win if the team gets the margin of victory that the team wins by during his 5 innings pitched. Then the reliever gets the Win if he pitches the half of the innings before the half-inning where the team gets the lead for the final time.
However, there's actually a rule that the official scorer may deny the Win to that reliever who makes a "brief appearance" if he was "ineffective" and there was a more effective reliever later in the game, i.e. Joba. I think Marte gave up 3 runs, some of which were tagged to A.J. http://mlb.mlb.com/mlb/official_info/of ... rer_10.jsp
"(2) four innings of a game that lasts five innings on defense, then the official scorer shall credit as the winning pitcher the relief pitcher, if there is only one relief pitcher, or the relief pitcher who, in the official scorer’s judgment was the most effective, if there is more than one relief pitcher.
Rule 10.17(b) Comment: It is the intent of Rule 10.17(b) that a relief pitcher pitch at least one complete inning or pitch when a crucial out is made, within the context of the game (including the score), in order to be credited as the winning pitcher. If the first relief pitcher pitches effectively, the official scorer should not presumptively credit that pitcher with the win, because the rule requires that the win be credited to the pitcher who was the most effective, and a subsequent relief pitcher may have been most effective. The official scorer, in determining which relief pitcher was the most effective, should consider the number of runs, earned runs and base runners given up by each relief pitcher and the context of the game at the time of each relief pitcher’s appearance. If two or more relief pitchers were similarly effective, the official scorer should give the presumption to the earlier pitcher as the winning pitcher.
(c) The official scorer shall not credit as the winning pitcher a relief pitcher who is ineffective in a brief appearance, when at least one succeeding relief pitcher pitches effectively in helping his team maintain its lead. In such a case, the official scorer shall credit as the winning pitcher the succeeding relief pitcher who was most effective, in the judgment of the official scorer.
Rule 10.17(c) Comment: The official scorer generally should, but is not required to, consider the appearance of a relief pitcher to be ineffective and brief if such relief pitcher pitches less than one inning and allows two or more earned runs to score (even if such runs are charged to a previous pitcher). Rule 10.17(b) Comment provides guidance on choosing the winning pitcher from among several succeeding relief pitchers."