eyJpZCI6IjkzMjY2MzQwIiwibmV0d29ya0NvZGUiOiI5NDIwOTk0MCIsImVmZmVjdGl2ZVJvb3RBZFVuaXRJZCI6IjkzMjEwMDYwIiwibmFtZSI6IkZyb250VG9wIiwicGFyZW50UGF0aCI6eyJpZCI6IjkzMjEwMDYwIiwibmFtZSI6ImNhLXB1Yi0zMDYxMTc2MDkyNzY2MzI4IiwiYWRVbml0Q29kZSI6ImNhLXB1Yi0zMDYxMTc2MDkyNzY2MzI4In0sImFkVW5pdENvZGUiOiJGcm9udFRvcCIsImRlc2NyaXB0aW9uIjoiIiwiaXNGbHVpZCI6ZmFsc2UsImlzTmF0aXZlIjpmYWxzZSwiYWRVbml0U2l6ZXMiOnsic2l6ZSI6eyJ3aWR0aCI6IjcyOCIsImhlaWdodCI6IjkwIiwiaXNBc3BlY3RSYXRpbyI6ImZhbHNlIn0sImVudmlyb25tZW50VHlwZSI6IkJST1dTRVIiLCJmdWxsRGlzcGxheVN0cmluZyI6IjcyOHg5MCJ9fQ==

Emmanuel Ledesma could not have timed his hat-trick any better for the Cosmos. (Photo courtesy of the NASL)

BROOKLYN, N.Y. — Carlos Mendes will play another day in his professional soccer career.

And so will the Cosmos.

They can thank, for the most part, Emmanuel Ledesma, who powered a hat-trick and set up a fourth goal to spark the Cosmos into the North American Soccer League playoffs behind a 5-2 triumph over Puerto Rico FC at MCU Park Saturday night.

Mendes, the Cosmos captain who played his final home game of his 16-year professional career, and second-half sub Lucky Mkosana added goals as New York broke out to its best scoring game of the season.

The result propelled the Cosmos (10-7-15, 45 points) into third place in the combined standings past North Carolina FC (11-9-11, 44), which visits Indy Eleven Sunday. North Carolina needs just a draw to clinch third.

“The attitude today was fantastic. Our second half was one of the best we’ve had all season,” Cosmos head coach Giovanni Savarese said. “The spirit of the team was great and we couldn’t have done better to help Carlos Mendes retire at home on this beautiful night.”

New York will hit the road to play either Miami FC or the San Francisco Deltas Sunday, Nov. 5.

“I’m very pleased that in a difficult year we were able to make the playoffs,” Savarese said.

Eighth-place Puerto Rico FC (5-17-10, 25) drew first blood in the 48th minute on the first two Emery Welshman goals past goalkeeper Jimmy Maurer.

Ledesma started his personal showcase in the 51st minute. The Cosmos put together some nifty passing from Eric Calvillo to Andres Flores to Ledesma who fired a shot from the top of the penalty arc past goalkeeper Austin Pack to equalize.

Five minutes later, Ledesma and the Cosmos were celebrating again with his second goal. This time he latched onto a pass from Jimmy Mulligan, shook Jake Stovall off his back and powered a 10-yard shot for a 2-1 lead.

Ledesma completed his hat-trick, running onto a through ball, Stovall and slotting the ball home for a 3-1 advantage in the 67th minute.

“We saw his class in the three goals that he scored,” Savarese said. “He was there in the moments that we needed him.”

Mendes got into the act in tyhe 75th minute, as he slipped a close-range effort into the lower left corner for a 4-1 margin off a Ledesma cross.

“I saw it in his face; He wanted a goal badly,” Savarese said. “He attacked like a center forward, the cross from [Ledesma] was fantastic, and at the end he scored a fantastic goal to close this night in a perfect way.”

The Cosmos needed those extra goals because Welshman chipped Maurer from close range to close the gap to two goals in the 84th minute.

Both Ledesma and Mendes got deserving ovations as they were replaced late in the match by head coach Giovanni Savarese.

Mkosana took over for Ledesma in the 79th minute and he found the net in the 95th minute.

Three minutes into stoppage time, Mendes was subbed for Richard Menjivar as the MCU crowd him a standing ovation while his teammates and some Puerto Rico FC players gave him hugs while leaving the field.