St Mirren goalkeeper Craig Samson is retiring with immediate effect to take up a coaching role at Sunderland.
The 34-year-old has started all but one of the Paisley side's 18 games this term, having returned for a second spell in the summer of 2017.
Sunderland, managed by former St Mirren boss Jack Ross, will visit in friendly next summer as part of the deal.
"I know it's not ideal timing, but it was an opportunity I couldn't pass up on," said Samson.
"We talked about the option of staying until January but we all agreed it was best that we let the club go on."
Samson played for Kilmarnock and Motherwell between his two stints with St Mirren and also had spells with Ross County, Dundee and Ayr United.
"He's been a great character and an ultimate professional in my time at the club and goes with our best wishes," said St Mirren boss Oran Kearney.
Ross described Samson as "a really good fit" for Sunderland.
"He has taken this big decision to come away from the playing side of things, but he recognises the opportunity he might have here to progress as an individual and collectively," he said.