The White Sox got an important piece of their team back Tuesday.

Shortstop Tim Anderson was sorely missed. That’s what he heard, anyway.

He’s happy to be back, giving the Sox a needed bat and perhaps some needed juice.

‘‘Just being able to bring that energy to the ballclub,’’ Anderson said before the Sox’ 5-2 loss to the Mets in 11 innings Tuesday at Guaranteed Rate Field. ‘‘Hearing from some of the guys that they missed me. I think they’re excited I’m back around. I’m excited, man. I’m ready.’’

Anderson’s return wasn’t enough. His sacrifice fly against Mets closer Edwin Diaz in the ninth inning scored Ryan Goins to force extra innings and put the Sox in position to steal a victory on a night Mets right-hander Noah Syndergaard was dominant.

But the Mets won it on back-to-back home runs by Jeff McNeil and Michael Conforto in the 11th against left-hander Josh Osich, handing the Sox their 16th loss in their last 21 games.

Turns out the Sox need more than Anderson’s mojo to win games.

‘‘This isn’t what we were expecting coming into the second half,’’ said right-hander Reynaldo Lopez, who allowed two runs in 51⁄ 3 innings after three strong starts to open the second half.

On the injured list since suffering a high sprain of his right ankle while fielding a grounder June 25 at Fenway Park, Anderson completed a rehab assignment Sunday at Class AAA Charlotte. As bad Sox luck would have it, he played all of a half-inning alongside third baseman Yoan Moncada, who left with a tight right hamstring after playing an inning in the field. Moncada, who was dealing with tightness before the game, is day-to-day.

Manager Rick Renteria said he didn’t think Moncada’s injury was serious.

‘‘He should be OK,’’ Renteria said.

The Sox also optioned outfielder Ryan Cordell to Charlotte and recalled right-hander Carson Fulmer to take the roster spot vacated by struggling right-hander Dylan Covey, who was shipped to Charlotte after he failed to retire a batter Sunday against the Twins.

That’s the way it has been going in Anderson’s absence. Since the All-Star-break, the Sox are 4-14. Without Anderson, they went 10-17.

The correlation isn’t direct. The Sox have other issues, including a .188 average with runners in scoring position in their last 21 games and losing rookie outfielder Eloy Jimenez to the injured list from July 17 till he returned Sunday. But Anderson had an All-Star-caliber first half and has an energy his teammates feed on.

‘‘Energy, the energy,’’ he said. ‘‘That’s something that allows me to be myself.’’

‘‘You’re looking at a guy who has put himself on the map with everyone,’’ Renteria said. ‘‘He’s an elite shortstop, and his defense speaks for itself in terms of how he’s grown out there. And offensively, he’s grown so much. Having [Anderson and Jimenez] in the lineup picks us up.

‘‘Everybody else sees what [Anderson] brings to the table. You feel a little more comfortable.’’

No one looked comfortable against Syndergaard, the subject of trade rumors before the deadline Wednesday, who struck out 11 in 71⁄ 3 innings. The Sox scored an unearned run against him, thanks to an error by third baseman Todd Frazier in the sixth.

Lopez, who has a 2.07 ERA in four starts since the break, needed 103 pitches to get through 51⁄ 3 innings. He allowed six hits, struck out six and walked four and held the Mets to 0-for-12 with runners in scoring position.

‘‘He did a heck of a job,’’ Anderson said of Lopez. ‘‘Hopefully he can continue to build on that and keep getting better.’’