With Kristaps Porzingis back in the locker room with knee pain and Tim Hardaway Jr. wearing a walking boot on the bench, Knicks coach Jeff Hornacek made a remark to Courtney Lee to start the fourth quarter.

“Fourth quarter, coach told me to step up, we need you,’’ Lee recounted. “I said, ‘I got you man.’ ’’

The Knicks were up five points and needed juice. Lee delivered it at Barclays Center on Thursday night as he erupted for 27 points — nine in the fourth quarter — as the Knicks beat the Nets, 111-104.

After a Ron Baker steal, Lee buried the key 3-pointer with 4:21 left, then danced at midcourt as the Knicks went ahead 100-92. A Lance Thomas 3-pointer with 1:22 remaining ended it and Barclays sounded like one of the best Garden crowds of the season. The fans chanted “Let’s Go Knicks’’ in the final minute.

Lee was a New Jersey Net in 2009-10 and can’t remember such a one-sided road crowd during their final year in East Rutherford.

“Were they saying ‘Let’s go Knicks’ — man, shoot,’’ Lee said. “That’s dope. That’s all you can ask for when you go on the road. The game was fun, 100 percent it turns into a home-court advantage for us when you got the crowd behind you every time you make a play, or get a defensive stop, they’re cheering for you.’’