Chemistry is a fickle thing in team sports. Some teams have it. Some don’t.

The 49ers have it, and it’s a significant reason they’ll be playing for the Lombardi Trophy in Super Bowl 2020 against the Chiefs on Feb. 2 in Miami.

The fact it was journeyman running back Raheem Mostert, playing for his seventh NFL team, who emerged as the star of the 49ers’ 37-20 rout of the Packers in Sunday’s NFC Championship game at Levi’s Stadium was as symbolic as it was fitting.

A week earlier, in the 49ers’ 27-10 divisional playoff win over the Vikings, it was a different running back, Tevin Coleman, who carried the load, rushing for two touchdowns.

“We are a team that can win any kind of way,’’ 49ers left tackle Joe Staley said. “This is a really hard team to play against and hard to beat.’’

Ask any 49ers players or coaches and they’ll point to the unmistakable chemistry on the team as a starting point to the team’s success.

“This is a very close locker room,’’ Staley said. “It’s been really special to watch everyone work together. We have genuine fun coming to work. That is really rare.’’

Staley, in his 13th NFL season, should be considered an authority on this. Just three seasons ago, when coach Kyle Shanahan and GM John Lynch arrived and were about to begin their rebuild, he was strongly considering retirement because it no longer was fun coming to work after going 7-25 in the two seasons before the new regime entered the picture.

Shanahan and Lynch talked Staley into hanging in for one more rebuild, and Staley is thankful he listened, because he’s having the time of his life. He’s going to the Super Bowl.

“There are no egos,’’ Staley said. “Nobody cares about what credit they get.’’

Indeed, quarterback Jimmy Garoppolo was asked to throw only eight passes Sunday and, in two playoff games, he’s thrown just 27 passes, completing 17 for 208 yards.

And he couldn’t care less.

Tight end George Kittle, the 49ers’ leading receiver with 85 receptions this season and 178 in the past two years, caught one pass for 19 yards Sunday and has four receptions for 35 yards in the playoffs.

He, too, couldn’t care less.

“I’ve been on some pretty tight teams, but this is right up there with them,’’ said veteran cornerback Richard Sherman, who won a Super Bowl with Seattle. “It’s really special to be a part of.’’

This chemistry, Sherman noted, has not coincided with wins.

“We had it before we were winning,’’ he said, referring to last season’s 4-12 team.

Both Lynch and Shanahan actually wondered at some points last season if the team was content with losing because the players got along so well together.

“Why is everyone so happy at 4-12?’’ Lynch asked himself.

“We had [chemistry] a lot better than I expected the first couple years and it didn’t result in winning,’’ Shanahan said. “Sometimes we almost [wondered], ‘Does that mean we need some worse guys?’ But we stuck with it. We brought in a few guys who thought the same as our [existing] guys. I feel like our team has been this way since the beginning. And when you do that and win, it only gets stronger.’’

Sherman, signed before last season, said, “Getting the right guys, that was a big part of it. Guys who want to do everything they can to win, guys that are selfless, guys that are compassionate, guys that show humility to one another.’’

An incident that took place in the divisional round win exemplified the selflessness that has permeated their locker room. Cornerback Ahkello Witherspoon was beaten on a long TD pass to Minnesota receiver Stefon Diggs early in the game and was immediately benched by Shanahan, replaced by Emmanuel Moseley.

Instead of pouting on the sideline, Witherspoon marched right up to Shanahan and offered to take Moseley’s snaps on special teams to keep him fresher on defense.

“Teamwork makes the dream work,’’ kicker Robbie Gould said.

“I love these guys … and when you have that kind of chemistry all through the organization, the sky’s the limit,’’ said veteran receiver Emmanuel Sanders, who played on Super Bowl teams with Pittsburgh and Denver before he joined the 49ers this season.

“It’s the team John and Kyle built,’’ right tackle Mike McGlinchey said. “We have weapons all over the place. It doesn’t matter who’s up or down. We have guys all over the place that are capable of taking over football games. Raheem is the biggest proof of that.’’

For more on the NFL playoffs, listen to the latest episode of the “Gang’s All Here” podcast: