The Mariners have lost their top remaining priority this offseason.

The Mets have outbid the Mariners for free agent Jorge Polanco, who has agreed to a two-year, $40-million deal to go to New York, sources told The Times early Saturday.

Seattle was Polanco’s No. 1 choice and he was “very torn” on the decision, but ultimately chose the best deal.

The Mariners had also offered a two-year deal, but did not match the Mets’ offer. The Mariners’ exact dollar figure is not known.

The Mets, backed by the wealthiest owner in baseball, Steve Cohen, needed to make a move after losing both their longtime first baseman, Pete Alonso, to the Baltimore Orioles and their star closer, Edwin Diaz, to the Los Angeles Dodgers this week.

This story will be updated.