It wasn’t pretty and it wasn’t easy, but the Nets opened their six-game Western road trip with the win they desperately needed.

After falling behind by as many as 13 points early in the third quarter, the Nets fought their way back with a 20-6 run to end the third, and came away with a 105-99 victory over the Jazz inside EnergySolutions Arena Wednesday night.

“Our defense was big,” said Nets coach Jason Kidd, who was working with a short bench after the Nets sent Jason Terry and Reggie Evans to the Kings for Marcus Thornton earlier in the day. “I thought the guys kept fighting. They stayed together. … We didn’t break.

“Being on the road against a team that’s playing extremely well, the defense got us back in the game, and then our bench was big. Everybody chipped in to get this win tonight.

The win was the first for Deron Williams in three trips to Utah since the Jazz traded him to the Nets three years ago. Williams finished with 19 points and seven assists in 36 minutes, including a 3-pointer with just over two minutes left that capped a 10-1 run and iced the win.

“It has gotten better and better each year,” Williams said of the crowd reaction toward him while sporting a bruise on his face after catching an elbow from Alec Burks in the fourth quarter. “Maybe in a couple years I will get all cheers … you never know.”

Joe Johnson had 27 points and six assists, and Andray Blatche had 25 points and six boards off the bench for the Nets (25-27), who moved past the Hawks and into a tie with the Wizards for fifth place in the Eastern Conference, and to move within three games of the Raptors for first place in the Atlantic Division.