The Boston Bruins weren't going to let playing against their former goalie Tim Thomas affect their game.

Thomas wasn't so sure he could feel the same way.

Reilly Smith scored the game-winning goal with 59 seconds left in the third period and the Bruins beat the Florida Panthers 3-2 on Thursday night.

Smith backhanded the puck into the net between the legs of Thomas after a faceoff in the Panthers' zone.

The goal spoiled Thomas' first game against his former team since joining the Panthers as a free agent.

"I, of course, tried to approach it just like any other game," Thomas said. "Having said that, it was a big game for me coming back after a while and then, obviously, facing your former team and a lot to-do around it. I was a little bit nervous today, but not too bad."

Thomas fell to the ice in disappointment when Smith's goal went in while the Bruins celebrated.

"Got close at the end there. We didn't want that to happen," Smith said. "It's a great feeling to score and help the team get a win."

Dougie Hamilton and Daniel Paille also scored goals for the Bruins, while Tuukka Rask made 27 saves.

Jesse Winchester and Kris Versteeg scored for the Panthers and Thomas stopped 37 shots.

Thomas overcame a shaky first period to turn in a solid game until giving up the goal in the final minute.

"It hurts the way it ended up," Thomas said. "I really wanted to guys in front of me to be rewarded after coming back in the third period after the way we started out."

The 39-year-old Thomas, who spent his first eight NHL seasons with Boston, returned to the lineup after suffering a groin injury on Oct. 8 that forced him to an early exit after giving up two goals on five shots in a 2-1 loss at Philadelphia.

Thomas helped the Bruins win the Stanley Cup in 2011. The two-time Vezina Trophy winner also won the Conn Smythe Trophy that season as playoff MVP.

Thomas followed that by going 35-19-1 with a 2.36 goals-against average and five shutouts in 2011-12, then sat out the 2013 lockout-shortened season.

"It was an awesome time there (in Boston)," Thomas said. "I don't know what else to say. This is a new chapter in my life; it's a new chapter in the Bruins' thing for them."

Trailing 2-1, the Panthers tied it at 2 with six minutes left in the third on Winchester's goal.

After the Panthers won a faceoff in the Bruins zone, Nick Bjugstad took a shot on goal. Rask blocked the shot, but lost control of the puck. It drifted in front of the crease and Winchester took a couple whacks at it before poking it in.

"I didn't want to cost us the game," Rask said. "I made a mistake there and they tied it up ... the guys came up big after that."

Florida closed to 2-1 in the second period after Versteeg took a pass from Jonathan Huberdeau in the right circle and wristed it past Rask at 12:32.

Boston went ahead 1-0 on Paille's goal in the first. Paille skated in from the left circle and his wrist shot went high into the net at 3:45.

It was a quick goal, but it turned out it wasn't going to be that easy against Thomas.

"He's a tremendous goalie. We had 40 shots and it still took us until that last minute," Paille said. "It was nice to get a couple early on him and have that lead but he bounced back and made it that much harder to get that third one."

The Bruins took a 2-0 lead later in the period on Hamilton's power-play goal. Hamilton took a pass from David Krejci just inside the blue line at the point and fired the puck past Thomas at 12:47.

Hamilton, a healthy scratch the past two games, notched his first goal of the season, aided by Zdeno Chara playing in front of the crease to screen Thomas.

"It's good to get the win but I had a lot of excitement and adrenaline in the first period being back in," Hamilton said. "We've been talking to try to get it up and make them save it with their hands and if they can't see it that's pretty tough. Z creates that goal."

NOTE: The Bruins broke an 0-for-12 power-play drought with Hamilton's first-period goal. ... The Bruins and Panthers will meet five times as Atlantic Division rivals this season. Boston won all three matchups against the Panthers last season, outscoring Florida 11-2. ... Panthers goalie Scott Clemmensen was scratched on Thomas's return. Jacob Markstrom remains the backup goalie.