The Bucks produced the final points of the fourth period and in the first extra session to keep the game alive, but they could not keep pace in the second overtime while suffering their fourth straight loss.
Anthony made two free throws with 1:32 left in the second extra period to give the Knicks a 101-98 lead. His 3-pointer with 50 seconds to go expanded the advantage to six points and he then made three more foul shots down the stretch to secure the win.
Anthony finished with 29 points and nine rebounds in what was only the eighth win for the Knicks this season.
Beno Udrih added 21 points while hitting five from beyond the three-point arc.
Milwaukee, which became the first team in the Eastern Conference with 20 losses, was led by Brandon Knight with a career-high 36 points. He made 13-of-25 from the field, six of the baskets being 3-pointers.