TORONTO — Carmelo Anthony didn’t have to deal with referee Tony Brothers, but the Knicks still ended up in a foul mood Saturday night.

Playing their first real close game of the season, the Knicks’ execution failed them on both ends of the floor and they fell to the Toronto Raptors 118-107 at Air Canada Centre.

Despite it being a tight game late, the Knicks (3-6) still had the same problems that have hurt them thus far: They can’t get stops, go through scoring lulls at the worst times, and they give up too many free throws.

The Raptors, who scored 65 second-half points, attempted 26 more foul shots than the Knicks and had 21 more points from the line. On Friday, Boston was plus-26 and plus 19 in both areas.

“When is enough enough?” Derrick Rose said. “We got to have that type of mentality. We got to continue to play, continue to go hard and continue to improve every day.”

They were down 107-105 after a Kristaps Porzingis’ dunk with 1:59 left, and didn’t make a field goal the rest of the way. Their only points were two Anthony foul shots with 22.4 seconds when the game was all-but over.

advertisement | advertise on newsday

Anthony, who was thrown out of Friday’s 28-point loss in Boston after being called for two technical fouls by Brothers, finished with 31 points.

But he shot 0-for-4 in the fourth with just those two free throws and had his shot blocked by Lucas Noguiera with 1:20 left and the Knicks down four.

“They switched,” Anthony said of the Raptors’ fourth-quarter adjustment. “They put a bigger guy on me, put a smaller guy on KP. We were trying to find that mismatch, work that mismatch. We’ve got to do a better job at executing down the stretch.”

DeMar DeRozan, the NBA’s leading scorer, had a brilliant game. He shot 11-for-23 and scored 33 points to lead Toronto (7-2). Norman Powell added 19 and Kyle Lowry 16.

Porzingis played with foul trouble again, and scored 21 points. Derrick Rose also had 21 points, and suffered a left shoulder stinger that he favored throughout the second half.

“I’m more hurt that we lost and the way that we lost,” Rose said. “The game is so close and so winnable. But we got to figure it out.”

Rose also was upset that he took only two foul shots. He felt he was attacking and not getting the benefit of the whistle.

“I’m going to the lane the same way everybody else is and I’m still not getting calls,” Rose said. “They said I throw myself into people but that’s the league. If I beat them there and I’m there before they get there, I think that’s a foul if there’s contact.

“They tell me they don’t see it. There’s three of them out there. I don’t see how three people don’t see it or me hitting the floor with someone jumping sideways, I don’t see how that’s not a foul.”

Down 87-85 to open the fourth, the Knicks continued to give Toronto open looks all over the floor. The Raptors just didn’t knock them down.

advertisement | advertise on newsday

They were 3-for-14 before DeRozan hit a three-pointer after being fouled by Porzingis. DeRozan’s free throw made it 101-97 Toronto with 5:48 left.

“That four-point play was a killer,” Hornacek said.

The Knicks tied the game at 101 with 4:21 to go after back-to-back Rose baskets by Rose. Powell put the Raptors back ahead on the next possession. It stayed that way until a Nogueira alley-oop dunk with 2:56 remaining made it 105-101.

After the Knicks closed to 107-105, Lowry drove past Rose and Joakim Noah for a layup to give Toronto a four-point edge.

Nogueira swatted shots by Anthony and Rose on two straight possessions and tapped out a key offensive rebound that led to a DeRozan driving layup and three-point play with under 30 seconds remaining.

advertisement | advertise on newsday

“We had a chance, that’s what you want on the road,” Hornacek said. “We just couldn’t get the stops. We fouled too much. We got to play defense without fouling.”