NASHVILLE, Tenn. — The Mets got their second choice.

A day after losing the Ben Zobrist sweepstakes to fill their second-base hole, the Mets landed Neil Walker in a straight up trade that sent Jon Niese to the Pirates on Wednesday. The deal was officially announced at the Winter Meetings after both players’ medicals were reviewed.

Walker, 30, had a .269/.328/.427 slash line with 16 homers and 71 RBIs in 543 at-bats last season for the Pirates. The arbitration-eligible switch hitter is due a raise from the $8 million he made last season. Indications are he will receive $11 million-$12 million.

“He’s a guy we had on our short list, but didn’t know if he would be available,” assistant general manager John Ricco said. “We view him as a real positive alternative to the deal we were looking to do the other day. He’s a switch hitter, he’s got some power and he’s a real good fit for our team.”

Niese, who grew up in the Mets organization, was expendable because of the club’s starting pitch depth, which could again include Bartolo Colon, in whom team officials have expressed interest, according to a source. But the Mets could also give Rafael Montero or Logan Verrett a shot at the fifth spot in the rotation until Zack Wheeler returns from Tommy John surgery rehab next season.

The lefty Niese will make $9 million in 2016 and his contract has club options for the ensuing two seasons.

Zobrist spurned the Mets on Tuesday, taking a four-year deal worth $56 million from the Cubs after the club had agreed to trade Starlin Castro to the Yankees. The Mets regrouped and discussed a trade for Walker, but were initially skeptical a deal could be struck.

But the momentum shifted Wednesday, and by early afternoon the Mets were confident they would get Walker from the Pirates.

Walker said he was somewhat prepared to get traded, but still surprised from the standpoint he had spent his whole life in Pittsburgh, born and bred in the city. He joins a Mets team that will look to win a second straight NL East title.

“[The Mets] obviously have one of the best pitching staffs in all of baseball,” Walker said. “That is first and foremost, but I think when you look at the Mets from last year, you see there’s not many glaring holes.”

Walker has struggled batting right-handed — he had a .575 OPS against lefties last season — leaving open the possibility Wilmer Flores or Dilson Herrera could factor in a platoon at second base.

“We’re looking for ways to give [manager] Terry [Collins] some options to mix and match and we do have some options from the right side to mix and match that would be complements to him,” Ricco said. “But Walker has played every day on some pretty good teams, so I think he’s going to get a lot of playing time.”

Collins said he could envision Walker hitting second in the lineup, behind Curtis Granderson.

Walker’s addition ends any possibility of Daniel Murphy returning to the team. The Mets were willing to pursue a one- or two-year deal with Murphy, according to sources, but believed he would receive a longer contract on the open market.

Murphy’s departure means the Mets will receive draft-pick compensation next summer, because he was extended a qualifying offer. Walker can become a free agent after next season, and the Mets could stand to receive a draft pick as compensation if he is extended a qualifying offer and then signs elsewhere.

Though the Mets had identified Herrera as a potential second-base candidate for next season, there was debate within the organization whether the 21-year-old rookie is ready for the job. Walker’s addition allows the Mets to move more slowly with Herrera, who would in all likelihood begin the season at Triple-A Las Vegas.

Niese, 29, went 9-10 with a 4.13 ERA in 33 appearances for the Mets last season. Murphy, Niese and Bobby Parnell were among the longest-tenured Mets — all three arrived during the 2008 season — but are no longer in the organization.

Walker admitted there will be an adjustment phase for him coming to New York.

“The Pittsburgh market is much smaller and it’s going to be different,” Walker said. “It’s going to be a lot more pressure, but I think being in baseball for 13 years I feel a lot of the ups and downs have led me to trust in what I’m doing and believe in myself and I think it’s going to be a great fit.”