Jets coach Rex Ryan swung his right arm around Mark Sanchez’s back as the downtrodden quarterback tried to knot a black necktie and fix his shirt collar in a quiet postgame locker room.

Not an hour earlier, a three-and-a-half year bond between the two changed dramatically. With 6:49 left in the third quarter, Ryan turned to offensive coordinator Tony Sparano and told him it was time to bench Sanchez for the first time.

Sparano delivered the message to Sanchez and Ryan told Greg McElroy, active in his first NFL game, to get his helmet on and warm up.

Now, the two were inches apart in full view of all the players following a 7-6 victory over the Arizona Cardinals in which the only points where delivered by a McElroy touchdown pass. Sanchez kept his eyes ahead, occasionally raising his voice above a whisper, bristling at the coach a few times and even aggressively shrugging his shoulders.

Ryan did his best to keep a comforting hand firm on Sanchez’s back.

“You get that feeling that, ‘I’ve seen enough and it’s time to make a change,’” Ryan said of the decision. “... I’ll always do what’s in the best interest of our football team and try to find ways to win.”

The change at quarterback energized a deflated stadium that booed Sanchez on and off the field throughout each of his 10 offensive series on a day that began with an interception. It saw McElroy execute two lengthy drives and toss his first career touchdown. It stunned a portion of the players and opened up a quarterback controversy that could arguably extend three ways when Tim Tebow gets healthy.

Ryan would not name a starter for next week, nor would he say which of his three quarterbacks gives the Jets the best chance to win.

Less than a year after giving Sanchez a three-year, $40.5 million extension, less than a week after Ryan proclaimed he’s still the starter and less than two days after quarterbacks coach Matt Cavanaugh said he’s still growing, the No. 5 overall pick in the 2009 draft was relegated to a pencil, a binder and a baseball cap. He would hear the play calls through a radio earpiece, including a seldom-used play-action pass that McElroy threw to Jeff Cumberland for the fourth-quarter, go-ahead touchdown.

“From the get-go, obviously the first play, it just wasn’t my day,” Sanchez said.

That first play, the first time he threw in the game, was intercepted by Cardinals safety Kerry Rhodes deep in Jets’ territory, an errant pass that sailed in the middle of the field. He finished 10-of-21 for 97 yards and three interceptions. Two other poor passes could have easily been picked.

In 10 drives with Sanchez Sunday, the Jets (5-7) gained 164 yards. In four with McElroy, they gained 152.

The tipping point for Ryan’s decision was a third-and-5 from the Jets’ 28-yard line with 6:59 remaining. Cardinals defensive lineman Ronald Talley swatted the short pass attempt away and the cacophony of boos continued.

Before grabbing the pencil and clipboard, Sanchez sought out his backup.

“He just gave me a hug and said, ‘Go get ’em,’” McElroy said. “It was the same thing I’d say to him. I really appreciate the way he handled it.”

When McElroy came in at the 4:48 mark in the third, the tenor of the game changed completely. “Sweet Child O’Mine” blared over the stadium speakers and a groundswell of cheers, building since the moment McElroy began warming up, bubbled over when he took the field.

Trailing the Cardinals 3-0, McElroy’s first drive took the Jets 69 yards for the score. Around him, the team was pumped with new energy, swinging their fists with each completion; spiking the ball to the turf with each run for a first down.

On a second-and-7 on the Cardinals’ 32-yard line, McElroy tucked the ball on a bootleg and scrambled toward the sideline, drawing a late hit penalty that set the Jets up with a first-and-goal. On third-and-1 from the 1-yard line, McElroy sold the play-action fake, rolled to the right side of the formation and flipped a short pass to a wide-open Cumberland.

“To tell you the truth, it was a bit of a floater,” said McElroy, who got a ride to the stadium that morning with left guard Matt Slauson. “I almost didn’t want to throw it but I let it go.”

The Cardinals got back within a point following a Kahlil Bell fumble before McElroy, with some heavy lifting from running backs Bilal Powell and Shonn Greene, drove 72 yards down field. They kneeled the clock out at the Arizona 2-yard line.

After the Cumberland touchdown, with the stadium shaking, Sanchez looked a lot like he would in the locker room while Ryan tried to console him. He kept his hands busy, scribbling on the clipboard and stared straight ahead.

In three-and-a-half years leading up to this point, Ryan had never doubted him.

Not once.

“I know what kind of young man he is,” Ryan said of Sanchez. “He’ll bounce back.”