The 28-year-old, who played 38 times for Leeds last season, found his place at Elland Road under threat following the arrival of Paddy Kenny from QPR.
"There were four clubs in for Andy, so we are pleased that he signed for us," Trotters boss Owen Coyle told the club website.
"We have a player who has a wealth of experience at this level, and also his signing will add competition for the keeper's jersey."
Lonergan added: "A few other clubs had offers accepted, but as soon as I knew of Bolton's interest and the way the club conducted itself during the talks, I wanted to come here.
"I've played nearly 250 matches in this league and I've come close to getting out of it. The squad here is Premier League quality and I believe it is best placed to get promoted.
"This is the perfect move for me and I'm delighted that it has all gone through."