SAN FRANCISCO -- The final chapter of Tim Hudson's major league career has been written.
It will finish with a mention of rival pitcher Brett Anderson.
Anderson collected his first-ever hit off Hudson in the right-hander's final game and later scored the first run of his career, contributing as a hitter, pitcher and baserunner to the Los Angeles Dodgers' 3-2 victory over the San Francisco Giants on Thursday.
Right fielder Andre Ethier tripled, scored LA's first run and drove in its third, helping the Dodgers move into a tie with the New York Mets in the overall National League standings with just their second win on a just-completed seven-game trip.
"Congratulations. What an incredible career," Anderson said of Hudson, who walked off the mound for a final time Thursday with 222 wins, a 3.49 ERA and 2,080 strikeouts. "I was lucky to get a hit off him."
The Dodgers (89-70), who have clinched the National League West title, finish the regular season at home with three games against the San Diego Padres.
The Mets (89-70), champions of the NL East, wrap at home with three against the Washington Nationals.
The team with the better record at regular season's end will secure home-field advantage in the best-of-five playoff series between the Dodgers and Mets that begins next Friday. The Mets hold the tiebreaker.
"We don't want to go to New York," Dodgers catcher Yasmani Grandal said. "Hopefully, we can sweep the Padres to give ourselves a chance to get home-field advantage."
Making his last start before he's expected to get the ball in Game 3 of the playoff series, Anderson had a two-hit shutout going until running into his first trouble of the day in the eighth inning.
Trying to protect a 3-0 lead, Anderson gave up an infield single to Giants center fielder Jarrett Parker, who advanced to second base on second baseman Howie Kendrick's error.
Pinch-hitter Angel Pagan ended Anderson's shutout bid one out later with a single.
Anderson got a second out but was then pulled in favor of right-hander Chris Hatcher, who allowed an RBI double to Giants second baseman Kelby Tomlinson, trimming the Dodgers' lead to 3-2.
Hatcher then retired Giants third baseman Matt Duffy on a fly to right to end the inning before closer Kenley Jansen worked a 1-2-3 ninth for his 35th save.
Anderson (10-9), who hadn't won any of his previous three starts, allowed two runs and four hits in 7 2/3 innings. He struck out three and did not walk a batter.
"The defense was great," Anderson said, singling out Chase Utley, who made a rare start at third base. "I thought I was efficient. I hope it carries over (to the playoffs), obviously."
The Dodgers did their scoring against Hudson in the first three innings.
Ethier led off the second with his triple and dashed home on Utley's sacrifice fly to left field.
That set the stage for a memorable third, one that neither Anderson nor Hudson will soon forget.
The Dodgers ended Hudson's day -- and his career -- in the inning when Anderson and Kendrick sandwiched a flyout between singles.
"I've had a lot of fun over the last 17 years," said Hudson, who left to a standing ovation and was greeted outside the dugout by a long line of teammates led by Madison Bumgarner.
"Today was very special for me -- the response of the fans and the response from my teammates. I just wish we had won the game."
For Anderson, it was just the sixth hit of his career.
"I just closed my eyes and swung the bat," he admitted.
Left-hander Jeremy Affeldt came on to give up a bloop single to Dodgers first baseman Adrian Gonzalez, scoring Anderson, who had a game plan as he rounded third and headed for home with Giants left fielder Mac Williamson's throw following him.
"No way I was going to slide," he said of the run first he has scored since high school. "Maybe in the playoffs, but not today."
Kendrick scored to make it 3-0 on Ethier's fielder's choice ground ball.
Making his 479th start, Hudson (8-9) allowed three runs, three hits and two walks in 2 1/3 innings. He struck out one.
Hudson's win total leads all active players.
"I feel very lucky to have played as long as I have," he said afterward. "I'm fortunate to have played on some great teams with great teammates. I'm very proud of the career that I've had."
Kendrick had two hits, including a double, for the Dodgers, who won for just the second time at AT&T Park in 10 tries this season.
Tomlinson had a double and a single for the Giants, who won the season series from the Dodgers 11-8.
The Dodgers outhit the Giants 6-5.
NOTES: Giants RHP Tim Hudson listed last season's World Series championship as the highlight of his career. ... Dodgers LHP Brett Anderson increased his innings total for the season to a career-best 180. ... Labeling OF Yasiel Puig's recovery from a hamstring injury "miraculous," Dodgers manager Don Mattingly said before the game that the club plans to reinstate Puig from the disabled list by week's end. ... Mattingly also announced that LHP Clayton Kershaw's final regular-season start Sunday will have a pitch count. Kershaw is being considered for the series opener against the New York Mets five days later. ... The Dodgers and Giants finished with identical 37-44 road records. ... Giants LHP Jeremy Affeldt pitched two-thirds of an inning on the same day he announced his retirement, effective at the end of the season. ... The Giants lost their 28th one-run game of the season.