Ravens coach John Harbaugh went down on a knee and partially covered his face. Quarterback Joe Flacco’s focus turned to overtime but not before he had some “bad thoughts.” Cornerback Jimmy Smith started yelling at any teammates in the vicinity and couldn’t help but wonder if the turn of events might ultimately cost the Ravens a playoff spot.

“It was a lot of frustration,” Smith said. “We’ve had an up-and-down season and that play was kind of the topper at that moment.”

Seconds away from celebrating their first victory in over a month, the Ravens watched the Cincinnati Bengals tie the game with no time on the clock on Andy Dalton’s twice-deflected, 51-yard Hail Mary touchdown to A.J. Green. Just like that, what once appeared to be a season-salvaging victory suddenly seemed headed for a season-sinking loss.

Except they still had overtime, and after stopping the Bengals on the first possession of overtime, the Ravens got a game-winning 46-yard field goal from Justin Tucker, whose right foot put an end to a wild game and put his team right back in the AFC North race in front of an announced 70,992 at M&T Bank Stadium. The 20-17 victory — their first since Oct. 6 — broke a three-game losing streak and put the Ravens (4-5) just 1 1/2 games behind the first-place Bengals (6-4) in the AFC North.

“I don’t know if this was exciting. It would’ve been more exciting if you were on Cincinnati’s side,” said Flacco, who threw two first-half touchdown passes but also turned the ball over three times. “I don’t know if it was more exciting as it was one of those ones where you go afterward, ‘Phew.’ I’m glad we won this one.”

The Ravens wouldn’t have officially been eliminated with a loss but their hopes of a third-straight division crown would have been all but dashed. Instead, after an afternoon of struggles and after failing to protect a 17-point lead, they’ll go to Chicago next week to play the Bears right in the thick of the AFC playoff picture with seven games to go.

No wonder safety James Ihedigbo walked up the tunnel to the locker room after the game, praising a higher power. Ihedigbo symbolized the afternoon for the Ravens. He had two interceptions and a role in the key fourth-down stop in overtime that gave the Ravens the ball. However, the game-tying Hail Mary actually hit off his hands before Green caught it near the back of the end zone.

“Team victory in so many ways,” Harbaugh said. “I think what it was all about in the end, and the thing I’m proud of as a coach, is the heart of our guys. I feel like they showed the heart of champions today. Where this leads us we will find out.”

There were certainly some positive developments. The Ravens finally started fast, taking their first lead in four games early in the first quarter on a 1-yard touchdown pass to tight end Dallas Clark, and building it to 17-0 midway through the second.

From backup quarterback Tyrod Taylor taking a handoff to nose tackle Haloti Ngata being inserted in a goal-line situation to top wide receiver Torrey Smith being targeted 14 times and catching his second touchdown pass, the Ravens showed the desperation to jump start a struggling offense.

The defense was dominant most of the game, intercepting Dalton three times, sacking him five times (2.5 of them by Elvis Dumervil) and shutting out the Bengals for the game’s first 34 minutes.

However, they certainly didn’t make an emphatic statement that they are ready to go on a torrid second-half of the season run either. They managed just 189 total yards of offense and were 3-of-16 on third downs. Flacco turned the ball over three times and he easily could have been intercepted two or three more times. At one point of the fourth quarter, the Ravens had less total yards than the Bengals had in penalty yards (134).

Their ground game also was again nonexistent as they had just 85 yards rushing and Rice was held to 30 yards on 18 carries. The Ravens gained one first down on a running play and six on penalties.

“Sometimes you have to win by any means necessary,” Rice said. “Winning heals a lot. Now, we have to get on a roll to get back where we want to be. It was a good team win. Number one, it gives you confidence. It’s great to get rolling with a little bit of confidence.”

The Ravens had talked all week about how they needed to just one win and things would hopefully click. They then went out and thoroughly outplayed the Bengals for the first 45 minutes, taking a 17-3 lead into the fourth quarter.

But they couldn’t put the game away. The offense bumbled through possession after possession, punting on five straight series after Smith’s 7-yard touchdown gave them the 17-0 lead. In the fourth quarter, the Ravens had the ball three times and Flacco threw one interception, fumbled once and then Sam Koch punted on the third one.

When Dalton, who was even more inept than Flacco for much of the game, hit rookie running back Giovani Bernard for an 18-yard touchdown, the Bengals trailed just 17-10 with 8:22 left in the game.

The two teams then traded turnovers — Flacco fumbled after he was hit by Carlos Dunlap and Dalton was intercepted by Ihedigbo for the second time — before the Bengals finally got the ball back at their own 40 with just under a minute and a half to play.

When Dumervil sacked Dalton right near midfield, it appeared that the Ravens finally had put away the Bengals. However, Dalton spiked the ball to stop the clock and then lofted a Hail Mary pass into the heavy winds at M&T Bank Stadium. The ball deflected off the first wave of players, seemingly making contact with wide receiver Marvin Jones’ shoulder. It came right to Ihedigbo but instead of knocking it down, it hit off his hands and went right to Green. When Green came down with the ball, the whole stadium got eerily quiet.

“Real quickly, you kind of say to yourself, ‘You’ve got to be kidding me. It is just not going right,’” Flacco said. “Me and Torrey just sat back down on the bench and just looked at each other and said, ‘Wow.’ But then pretty quickly, you get back up, take the field and see what you can do.”

Jimmy Smith, in particular, was caught on cameras yelling at Ihedigbo though the two joked about the incident after the game. And the Ravens certainly didn’t have much time to dwell on the play.

The Bengals won the toss and quickly advanced into Ravens’ territory. But on third-and-2 from the Ravens 33, Bernard was stopped for no gain. Bengals coach Marvin Lewis opted to go for it, knowing that Mike Nugent would be kicking a 50-yarder directly in the wind on the same end where he missed from 42 yards earlier in the game.

On fourth-and-2, Dalton threw a screen pass to Bernard, who was met by a couple of Ravens. He cut across the field, where he was finally brought down by Ihedigbo and Corey Graham for a loss of 11.

“We knew we had to rat pack him,” Dumervil said. “We had 11 guys on the field pursuing him. Give credit to [Ihedigbo]. He was chasing him all over the field.”

Starting at their own 44, the Ravens needed just two first downs to get into Tucker’s field-goal range. Late in the fourth quarter, Tucker was telling teammate Kyle Juszczyk on the sideline how he felt like he had pretty much seen it all in less than two seasons in the NFL.

Moments later, Green caught the ball in the end zone. After Tucker split the upright, the kicker was able to laugh about it, and the Ravens breathed a sigh of relief.