LONG BEACH — With its backs against the wall and its No. 1 national ranking on the line, the UCLA men’s volleyball team found its rhythm in the nick of time on Friday night against No. 2 Long Beach State.

The Bruins were down 14-10 and 20-18 in the third set and on the verge of getting swept when they rallied to win 25-22 and extend the match.

UCLA (9-0) then carried that momentum into the fourth set and won 25-19 before ending the match with a 15-10 victory in the fifth and deciding set.

“For us to come in here and experience that adversity and that stress and that embarrassment at times. It was embarrassing, right? You want to put on a great show,” UCLA coach John Hawks said. “They got a great crowd and I’m just happy our guys responded.”

LBSU (8-1) won the opening set 25-16 on a service error by Sean Kelly.

Long Beach took its first three-point lead at 10-7 on a service ace by Jake Pazanti and stretched the lead to 13-9 on another ace by Jackson Cryst.

Skylar Varga’s solo block made it 18-11 and Ryan Peluso ended the run of four straight points by spiking an overpass to give LBSU a 20-11 lead.

Both teams had six service errors each in the first set.

Long Beach took the second set as well, 25-22.

UCLA took its biggest lead through the first two sets when it scored three straight to take a 7-4 advantage in the second.

LBSU answered back with three straight points of its own, two on service aces by Alex Kandev that went untouched by the Bruins, giving Long Beach a 11-10 lead.

The set stayed close until LBSU scored four straight points to move ahead 23-20.

A kill by Daniil Hershtynovich gave Long Beach set point at 24-21. Kandev then delivered a spike that was initially ruled to have gone wide, but Kandev immediately asked for a video review because he believed his spike went off the block of UCLA and the replay confirmed it did, giving the set to LBSU.

“These guys are human,” Hawks said. “They made a lot of hitting errors in the first couple sets and we haven’t done that all year. It was a little uncharacteristic. I stayed with our guys, because I believe in them. I trust them.”

After scoring the final three points of the third set to win 25-22, UCLA took advantage of its new life and played is best set in the fourth, again taking a 7-4 lead like in the second set, but not giving it up this time. The Bruins scored three straight points to turn a 16-14 lead into 19-14 advantage, reached set point on a kill error by LBSU and won it 25-19 on a kill by Kelly, his 13th of the match.

UCLA scored the first three points of the fifth set, but LBSU managed to knot the score at 5-5 on back-to-back service aces by Varga.

Long Beach even moved ahead 8-7 before the teams changed sides.

A key point in the final set came when LBSU appeared to cut the lead to 10-9, but UCLA challenged for a touch on a block that went out of bounds and the replay confirmed that Zach Rama’s kill went off the block, changing the score to 11-8.

UCLA reached match point on Rama’s fifth kill of the final set and won it on a back line service ace by Andrew Rowan.