The Stars have agreed to terms with defenseman Sergei Gonchar on a two-year contract, according to Stars GM Jim Nill. The contract, for $5 million a season, according to a source, still needs to be signed.

“We’re excited,” Nill said Saturday afternoon. “We see him as a significant player who will play a big role for us. He’s one of the greatest scoring defensemen in the game right now, and we feel he still has plenty of game left.”

The Stars on Friday acquired the rights to Gonchar from Ottawa for a conditional sixth round draft pick. Gonchar, 39, could have become an unrestricted free agent July 5. Gonchar had to waive a no-trade agreement to give the Stars negotiating rights.

Ottawa will now get the Stars’ sixth round pick in the 2013 entry draft.

Gonchar is a four-time All-Star Game participant who the Stars see as a potential No.1 defenseman, despite his age. Gonchar has been a 25-minute player for most of his career, and averaged 23:59 with Ottawa last season.

“Players like this, they’re real pros. That’s why they are playing so long,’’ Nill said. “You look at what he did last season, and he was a top NHL defenseman. I think any organization would want to add a player like that.’’

Gonchar tallied three goals and added 24 assists for 27 points in 45 games with the Senators. That ranked 16th among defensemen in the NHL. He also played 37 games for Metallurg in the KHL during the lockout last season, and tallied 29 points (three goals, 26 assists) there.