"I told myself, "I'm going to take the shot and if I do miss it, they aren't going to have a lot of time left," Williams said. "I had to set it up right."
Williams had 30 points, including an awkward, 20-foot jumper with 3.1 seconds left, and 10 assists to lift the Bucks a 107-105 victory over the Knicks on Sunday to snap a six-game losing streak.
New York nearly came back anyway after Williams' shot.
Jamal Crawford hit an open 3 to make it 106-105 and the Knicks fouled Williams with 0.4 seconds left.
Williams, who meant to miss his second free throw, made it, giving the Knicks a chance to tie or win.
"The way things have been going lately when I made it I thought we were going to overtime," Williams said. "We played too well today to get a moral victory."
But Crawford couldn't get a 3-pointer off from the corner in time.
"I was trying to rush just to get it up," said Crawford, who wasn't sure if the shot even would have counted.
Williams, who missed the last nine games after spraining his left shoulder in a collision on Jan. 8 at Denver, brought some desperately needed energy and bailed out the struggling Bucks after they nearly blew a 13-point lead with just under 9 minutes to play.
Milwaukee, which had lost 11 of its last 12 and nearly completed its first winless month at home in more than 15 years, outhustled the Knicks for most of the game before New York made a furious rally.
"We just can't put ourselves in situations like that," said Stephon Marbury, who finished with 15 points. "We put ourselves in a tough situation where we had to fight to come back. Those guys, they hadn't won a game, so we kind of expected them to come out and play the way they played. For us as a team, we've got to come out more prepared."
Crawford, who scored 17 points in the fourth and finished with 26, started by scoring the Knicks' first 10 points of the final quarter. He picked up his fifth foul with 5:05 left and the Knicks down 91-85, but New York didn't fold.
Andrew Bogut, who had 18 points and nine rebounds, finished a fast break with a dunk with 1:33 left to make it 102-95, but Marbury scored the next five points off two free throws and a long 3-pointer to make it 102-100 with a minute to go.
Williams and Marbury traded baskets before Williams hit his running jumper with Marbury tightly defending him with 3.1 seconds to play.
"I'm just glad he didn't shoot it too early," Bucks coach Terry Stotts said. "We got on him at halftime for doing that at the end of the first half. ... As good as shot it was, I thought the timing of it was even better."
Williams' early attempt just before half led to Nate Robinson sinking a shot from halfcourt at the halftime buzzer to pull the Knicks to 52-47.
Brian Skinner had a season-high 14 rebounds as Milwaukee held a 46-43 edge against the second-best rebounding team in the league, even though the Knicks got Eddy Curry back after he missed a game with a sore left calf. Curry, averaging 19.4 points and 7.1 rebounds, looked like he was poised for another big game early on. He made his first five shots, but finished with 15 points and four rebounds.
"I'm stiff and not quite where I want to be," said Curry, who added he won't miss another game because of the injury.
Crawford nearly showed up too late to help the Knicks following his career-best 52-point effort against the Heat on Friday night. He missed his first six shots before scoring on a layup with 1:12 left in the first half and finished 9-of-24 from the field.
"I think the first game after a big game like that is probably the hardest," Crawford said. "My teammates encouraged me to stay with it. They weren't typically bad shots, but they just weren't falling."
Williams, still missing starting backcourt mate Michael Redd (strained knee tendon), was quietly having a breakout season before being injured. He is one of three players in the league averaging 17 points, five rebounds and five assists, along with LeBron James and Kobe Bryant.
"He had a spark," said Stotts, who led the Bucks to a 7-0 record at home last month. "We're trying to get back in to the style we were playing in December and Mo was a big part of that."
The teams combined to miss their first seven free throws before Jerome James, hit two with 28 seconds left in the first quarter. The Bucks finished 16-of-25 from the free-throw line and the Knicks went 14-of-24 leaving coach Isiah Thomas frustrated. "We can't hit our free throws. If we made our free throws, you can add seven or eight wins to our win column." ... Due to national television restrictions, the game was shown in New York at 6 p.m. on a tape-delay.