The Mets’ sixth win in seven games was followed by a devastating loss.

Manager Terry Collins announced after Wednesday’s 5-2 win over the Marlins that second baseman Neil Walker likely is opting for season-ending surgery for a herniated disk, leaving the Mets without one of their most valuable bats for the final stretch of the playoff race.

Walker received a second opinion on his back condition earlier in the day, leading to the decision his manager wasn’t expecting.

Collins didn’t know the details of the surgery yet, but said it would be performed immediately. The disk injury is causing weakness in one of Walker’s legs and numbness in one of his feet.

Walker, who has missed the past four games, originally was ruled as day-to-day with the ailment. He is expected to address the media on Thursday.

“After all the evidence has been gathered, he thinks that’s where he’s probably headed,” Collins said. “We’re certainly very disappointed that it’s come to this. He’s had a tremendous year for us, but certainly he makes the decision and it’s in his best interest.”

After the Mets’ third straight win, everyone in the clubhouse hadn’t yet heard about Walker’s decision, then immediately felt the sting of the latest injury to hurt their chances at a postseason return.

In his first season with the Mets, Walker has hit .282 and leads the team with 116 hits, ranking second in home runs (23), RBIs (55) and walks (42).

“It’s definitely huge,” Wilmer Flores said. “This year, Walker has been a big part of this team. It’s a shame. We’ve got to deal with it, but we’ve had a lot of injures. We got to keep playing with what we have.”

Your browser does not support iframes.

Before the game, Collins thought there was a good chance that Walker would be back soon and noted the second baseman could play now, but was being held out to avoid putting the 30-year-old at further risk of injury. Another factor was that Walker wasn’t confident he could finish a game he started, unsure when the pain would prevent him from being able to play.

Walker’s back injury has been a problem all season at varying levels.

“He’s got to get some strength back in his leg in order to play,” Collins said. “It’s been on and off all year. As Neil puts it, he has grinded it out, the discomfort level. Sometimes it goes up, and when it goes back down he needs rest until the strength comes back up again.”

The end of Walker’s first season with the Mets also may be the end of his tenure with the team. The longtime Pirate becomes a free agent after the season.

Even with much at stake financially, Collins said before the game he didn’t think Walker’s plan going forward would be determined by anything beyond this season.

“He didn’t say one thing about next year. He didn’t say one thing about down the road,” Collins said. “He just said, ‘Look, right now I’ve got to help out and I don’t know if I can.’ ”

Walker will join David Wright, Matt Harvey, Lucas Duda and Juan Lagares as the Mets’ regular starters likely lost for the rest of the season.