With 4:02 remaining in the period, New York was down 70-63 after a turnaround jumper by Ellis. But the Knicks went on an 8-0 run as Anthony hit a 3-pointer and Raymond Felton connected on an alley-oop with Chandler, who finished with nine points.
Smith then hit a 3-pointer to make it 71-70 with 2:04 left.
Ilyasova drove to the basket and was fouled by Chandler before making a free throw that tied it at 71. Samuel Dalembert briefly gave the Bucks a 73-71 lead with a tip-in after Ilyasova stole the ball from Anthony.
But the Knicks answered right back. Anthony scored on a drive and was fouled, converting a three-point play that put New York ahead for good with 42.5 seconds left in the third.
"For us offensively, we just kind of hit a wall there. We couldn't score enough points," Bucks coach Jim Boylan said. "We were searching for offense pretty much the whole second half. We only had 20 points in the third quarter and we've been a pretty good third-quarter team coming out of the locker room. But tonight for whatever reason, we just didn't have enough."
The Knicks opened the fourth quarter with another run. Stoudemire made a pair of free throws and a hook shot in the lane to give the Knicks a 78-73 lead before Milwaukee called a timeout after Pablo Prigioni drew a charge on Mike Dunleavy with 9:35 left.
Milwaukee missed its first five shots and turned the ball over twice before Jennings' layup made it 78-75.
The Knicks then went on an 8-2 run and never looked back. Iman Shumpert scored on a layup and Chandler followed with a dunk to make it 82-75. Marquis Daniels answered with a layup for Milwaukee but Shumpert made another basket and Felton followed with a 3-pointer to make it 87-77 before the Bucks called timeout with 4:58 to go.
"We've got to get after guys from the start to finish," Stoudemire said. "So we started off a little bit slow tonight but we were able to get it going in the second half."
NOTES: The Knicks honored former New York City Mayor Ed Koch during a timeout in the first quarter. Koch died of congestive heart failure Friday at 88. ... New York Yankees ace CC Sabathia was in attendance. ... The Bucks had won 12 of 14 against the Knicks before losing four straight. ... The Bucks are 0-12 when held to 90 points or fewer this season. They scored 88 in a loss to the Chicago Bulls on Wednesday night.