The Canadiens will also receive a fifth round draft pick in 2007 while the Stars get a sixth-round pick in 2008.
Ribeiro, a career Canadien, said he was shocked by the move.
"I'm disappointed and sad at the same time," the Montreal native said. "I didn't expect this now.
"There were rumours last year that I'd be traded, but I didn't think about it this year. I just concentrated on getting ready for the season. I guess Montreal wanted defence and Dallas wanted a centre. It's a great city for me. No winter. No snow. So I'll be happy."
Tomas Plekanec was in Ribeiro's spot on a line with Alex Kovalev in a pre-season game Saturday night against Ottawa.
Montreal is short of defencemen with injuries to Francis Bouillon and Jean-Philippe Cote, and with Sheldon Souray playing with a sore shoulder.
The Canadiens claimed rearguard Patrick Traverse on waivers from San Jose on Thursday.
The six-foot-one, 220-pound Niinimaa, 31, is a 10-year NHL veteran. He has 54 goals and 262 assists in 700 career games.
Niinimaa was traded to Dallas by the New York Islanders last January, but the Stars are deep on defence after acquiring Darryl Sydor and Jaroslav Modry in the off-season.
Ribeiro has played 276 career games for Montreal, collecting 50 goals and 103 assists.
"Dallas has great players, a great team, and they'll be playing for the Stanley Cup," he said. "I always dreamed of winning a Stanley Cup here (in Montreal), the 25th, but I guess it won't happen."