SAN FRANCISCO (AP) -- Javier Lopez tested the market just as he wanted to do, then wound up right back where he has become so comfortable at this stage of his career.
On Tuesday, the free-agent left-hander finalized his new $13 million, three-year contract to stay with the San Francisco Giants.
Lopez agreed to terms on the deal last Thursday, but needed to travel to the Bay Area to undergo his physical before signing the contract.
''I feel like I went through the process the way I wanted to, obviously with keeping the Giants in the know and keeping them front and center in the whole situation,'' Lopez said. ''I did just want to reach out and see what kind of interest there was around the league and gauge the thoughts of my family, but ultimately San Francisco was No. 1 the entire time and that's ultimately how it worked out.''
He will earn $4 million in both 2014 and '15 and $5 million in 2016. The contract includes up to $500,000 in incentives based on games pitched.
The 36-year-old Lopez went 4-2 with a 1.83 ERA in 69 appearances and 39 1-3 innings this year. He just completed an $8.5 million, two-year contract.
Keeping Lopez was among the top offseason priorities for general manager Brian Sabean after his club missed the playoffs following its second World Series title in three years during 2012.
In fact, Sabean approached Lopez leading up to this summer's trade deadline - when many figured he might be someone the Giants tried to deal - and expressed his support of the pitcher for not only 2013 but beyond. For Lopez, that gesture meant so much, along with the Giants doing what they could to keep much of the pitching staff together not to mention the entire roster.
''I do think that obviously any time you're going into your last year before free agency, the trade deadline does become a barometer not only of what your future is with the club, but what the team thinks of you,'' Lopez said. ''To have Sabean call us all in and tell us he wanted us to continue to be Giants not only this year but going into future, I think that was a big deal, I really do. I've never had a GM do that before.''
San Francisco acquired Lopez in a swap that sent John Bowker and Joe Martinez to the Pirates in 2010, and Lopez emerged as a reliable option for manager Bruce Bochy as the club made an improbable run to the city's first World Series championship since moving West in 1958.
The signing of Lopez to a multiyear deal gives the Giants two lefties in the bullpen for the next two seasons. Jeremy Affeldt received an $18 million, three-year contract last November.
In addition, starters Madison Bumgarner and Matt Cain are signed long term, along with 2012 NL MVP and batting champion catcher Buster Posey. Two-time NL Cy Young Award winner Tim Lincecum landed a $35 million, two-year deal late last month.
The Giants had to clear a spot on the 40-man roster for Lopez, so left-hander Jose Mijares was outrighted to the minors. He then cleared waivers and chose to become a free agent.