A ticky-tack foul call on Iman Shumpert helped cost the Knicks a giant victory over the Pacers Wednesday at the Garden.

Everything was going storybook for the Knicks against all odds as they led the powerhouse Pacers by three points with 9.2 seconds left in regulation.

Indiana’s Paul George fired up a 3-pointer that became a wild air ball and the Knicks looked as if they had shocked the Pacers.

“I thought we had the game won,’’ Carmelo Anthony said.

But a foul was called on Shumpert, giving George three free throws. Replays showed Shumpert grazed George’s elbow, but it was suspect whether a foul should have been called in that pivotal stage. The Knicks were in shock, George sank all three free throws to force overtime and the Pacers ran away with a 103-96 victory.

Yes, the Knicks can’t get a break on their home court. It was their sixth straight loss at the Garden and the Knicks fell to 3-8, though just 1 1/2 games behind in the dreadful Atlantic Division. A four-game road trip is on tap, starting in Washington before heading to the West Coast.

The Shumpert foul ruined a solid, bounce-back night from a down-in-the-dumps Carmelo Anthony, who finished with 30 points and 18 rebounds. He heard “MVP’’ chants for the first time this season when he was at the foul line, where he went 10-for-10.

“When you’re going through times like these, it seems nothing is going your way,’’ Anthony said. “We’re stuck in the mud and we got to get out of it. This was a tough one to slip out of our hands.’’

After George made all three free throws, Anthony had one last chance to win it but missed a turnaround in the lane, shooting it too hard. Ultimately, Anthony was outplayed by George, who finished with 35 points — 21 in the fourth quarter and OT.

Coach Mike Woodson, who said before the game the officials “blew’’ a call against Anthony in Detroit, didn’t defend Shumpert, who is on the trading block. No surprise there.

Woodson instead praised referee Joey Crawford, perhaps deciding it was time to play nice with the officials in an attempt to get better calls in the future.

Woodson said it was discussed with Shumpert to possibly foul George intentionally before the shot once he got the handoff. Woodson said Shumpert played it “lazily.’’ Then he was too aggressive.

“The worst that can happen is he hits a 3 over you and it goes into overtime like it did,’’ Woodson said. “But you can’t foul him. I looked at the tape and he got him on the elbow and Joey made the correct call.’’

“I contested the shot,’’ Shumpert said. “It doesn’t matter what I think. They called a foul. They can’t change the call now. It’s over.’’

When asked if the trade talks has bothered him, Shumpert said, “We got to win games. It’s not about being traded.’’

The Knicks entered the game injury-riddled and emotionally battered, facing the same Indiana club that ruined their season last May in the second round of the playoffs. Anthony was going through a rare confidence crisis as well, according to a confidant.

The Knicks jumped out to a 13-0 lead against their playoff tormentors and led much of the way.

“I saw a lot of positives,’’ Anthony said. “There were a lot of things we can take away from this game as far as effort. We’ll build on this.”