The 26-year-old, who has found himself sidelined by Dens Park boss Neil McCann since early November for an unspecified disciplinary problem, will provide competition with Ofir Marciano for the No.1 jersey at Easter Road following the recent shoulder injury to Ross Laidlaw.
The Edinburgh-born stopper came through the youth ranks at Aberdeen, but made his name at Alloa Athletic before signing for Dundee. His form for the Dee earned him a call-up to the Scotland squad for matches against Qatar and the Republic of Ireland in the summer of 2015.
Bain, who will join his new team-mates for their winter training camp in Portugal this weekend, said: “I am delighted. From the outside looking in, the side have had a fantastic first half of the season, and I hope to help them build on that in 2018.
“It’s a strong group of players, I am excited and hopefully I can hit the ground running and force my way into the manager’s thoughts.”