(Getty Images) (Getty Images)

Back on the floor for the first time in three weeks, Bradley Beal didn’t think he was going to have the chance to rescue the Wizards and end their misery at Madison Square Garden with a game-winning layup.

With 2 minutes 48 seconds left in the Wizards’ 102-101 victory over the New York Knicks on Monday night, Beal looked over at the scorer’s table and saw Trevor Ariza getting ready to enter the game.

Beal had scored 13 points in 27 minutes, and figured that he had reached his minutes limit as he continues to recover from a right leg injury. He had also just made a costly turnover on the previous possession that allowed the Knicks to tie the score at 94.

“I honestly thought he was taking me out,” Beal said of Coach Randy Wittman. “I was like, ‘Dang, I’m coming out.’ ”

Beal wasn’t coming out. Ariza motioned for Trevor Booker instead, leaving Beal with the opportunity to script his own “miracle” finish in an arena where legends have been made. The Knicks pushed ahead to take a 98-94 lead, but Beal sandwiched two three-pointers around two Andrea Bargnani free throws to tie the score at 100.

Then, after Beno Udrih made one of two free throws with 24.5 seconds remaining, Wittman drew up a play for Beal and used misdirection on the other side to confuse the Knicks. John Wall handed off the ball, ran to the painted area to set a screen on Bargnani and Beal scanned the floor, waved off a screen from Marcin Gortat, then darted directly to the basket for a relatively easy layup.

“We were lucky enough to have the ball on that last possession,” Wittman said. “Brad made a helluva a decision there. I think they were going to try to trap Bargnani, but he faked pick-and-roll and drove baseline and got to the rim. There wasn’t any other bigs down there.”

Gortat had set picks to get Beal in mismatches with Bargnani on the previous two possessions, but Beal anticipated that Bargnani would be overly aggressive. When he noticed confusion from the Knicks, Beal didn’t hesitate.

“There was absolutely nobody paying attention,” Beal said with a smile. “It was a great play by Witt. A lot of commotion, guys were trying to switch. They had no idea where the ball was going.”

Gortat watched in amazement as Beal cruised to the hoop.

“I don’t think they were on the same page defensively. I don’t know what they were trying to do, they screw up and I’m happy that Bradley scored,” Gortat said with a smile. “It’s about time for us to win a game. Bradley was the crucial thing. He came ready to play and the last three or four minutes, he was incredible. Made big points for us.”

The Knicks continued to be confused after Beal’s layup. Udrih argued with Bargnani. Carmelo Anthony called for the ball, hesitated as he waited in vain for Knicks Coach Mike Woodson to call a timeout — even as he had three to burn — and threw up a running shot off one leg that hit nothing but backboard. Beal grabbed the rebound and tossed the ball behind him before celebrating at midcourt.

“Did they really? Oh, wow,” Beal said when told the Knicks had three timeouts. “Hey. That probably could change a few things. I’m glad he didn’t call one.”

After the game, Beal had to have his leg checked by the trainers, which will be a regular routine going forward.

“I do it every day. That’s going to be a pain in the butt,” Beal said. “I’ve been doing it for the last three or four weeks already. It’s going to be a hassle, but I have to do it every day. I’m fine. No issues, no pain anywhere, hopefully, I’ll be able to play well and we can keep this thing going.”

Beal scored eight points in the final two minutes of the game and was grateful that he had a chance to help his team snap a four-game losing streak and deliver its first victory at Madison Square Garden in more than seven years.

“I’m happy he left me in there. He told me going forward he would take me out,” Beal said of Wittman. “Hopefully, we’ll be in pretty good position to win the games and I have faith in my teammates to be able to close it out.”