On a night the Cosmos desperately needed a win, a couple of seconds of brilliance by Yohandry Orozco gave them a vital lifeline. The Venezuelan international midfielder scored a marvelous goal in the Cosmos’ 1-0 victory over the Carolina RailHawks at Shuart Stadium on Sunday night.

The win moves the Cosmos (3-2-0, nine points) within three points of first-place Carolina (4-1-0, 12). Had they lost, they would have been nine points adrift with five matches left in the 10-game North American Soccer League spring season. The spring champ gets an automatic berth in the four-team playoffs in November.

“If we would have lost this game or even just tied, the spring season would have been pretty far out of reach,” goalkeeper Jimmy Maurer said.

The Cosmos avoided a third straight defeat. They lost at Indy Eleven in stoppage time, 2-1, on April 16 and allowed Minnesota United to take a 1-0 victory with a 90th-minute goal on April 23.

“This game has just a little extra for us to be able to show that we can battle, can close games, can be able to beat a team like Carolina,” coach Giovanni Savarese said. “These type of wins gives you more confidence.”

Orozco, who had played only 10 minutes this season, was the scoring hero. Savarese saw what he liked in practice and started Orozco, who produced magic in the 45th minute before 2,419 fans.

advertisement | advertise on newsday

Defender Gabriel Farfan launched a long pass from the back to Orozco, who put the moves on Drew Beckie and Haitian international James Marcelin on the left side of the box before depositing the ball to the far post past goalkeeper Brian Sylvestre.

“Since yesterday I was thinking about scoring today and I was thinking about it very hard,” Orozco said. “It works out when you think about it a lot.

“You can think about you can actually score and do something nice, but you can never think about scoring a goal like that.”

Maurer came up big, stopping Marcelin with a spectacular save in the 85th minute and denying Tiyi Shipalane in front moments later.

“Those plays are tough,” Maurer said. “You’re a split- second off, you look like an idiot and it’s a goal. Fortunately, I was able to read it early and get there on time. Shipalane was so fast, I was worried for a second.”