Bob Nightengale

USA TODAY Sports

ST. LOUIS — Major League Baseball’s carnival act, which has amused us for years with its own version of clowns, fortune tellers and Tilt-a-Whirls, has left town.

The Miami Marlins, before our very eyes, have become an honest-to-goodness baseball team, turning 13 years of anguish and comedy into legitimate playoff contention.

“What we went through last year was kind of a circus,” says Marlins catcher J.T. Realmuto, whom the Marlins are calling their unheralded hero. “We were told things would change, and they did, starting with a new manager. So we knew coming in this season would be different, and it’s been a positive atmosphere.

Cool summer: Indians ride wave of glory to commanding AL Central lead

“If we get to the playoffs, and win the World Series, that would make five years of misery go away.’’

Well, make it 13 years of misery, the last time the Marlins were even in contention the final week of a baseball season.

This year, under manager Don Mattingly, the Marlins at 49-42 are a genuine contender. They won again Sunday, 6-3 over the St. Louis Cardinals, and are tied for second place with the New York Mets in the NL East, and also for the second wild-card spot.

They lead the league in hitting at .273, and are only the fourth team in the last 40 years to have five hitters batting .300 or better at the All-Star break. All-Star closer A.J. Ramos has 29 saves, and newly acquired All-Star reliever Fernando Rodney, now their setup man, has a 0.98 ERA and saved 17 games for San Diego.

Sure, just like a whole lot of contenders, they could use another starter. Ace Jose Fernandez, 11-4, 2.52 ERA, is their only starter with more than six victories or a sub-3.60 ERA. They’ve had only one starter last past eight innings in a game this season. They don’t even have a fifth starter for Tuesday night’s game against the Philadelphia Phillies, let alone for the pennant stretch.

Yet, here they are, hanging with the big boys in the National League, vowing that you still haven’t seen the best of them.

“I think it started in the offseason when Donnie (Mattingly) first came in,’’ Marlins president David Samson told USA TODAY Sports. “When we hired him, I told him, “Hey, we’re really good at interviewing managers, because we do it every year, right? But we said, “This is it. This is our last one.

“We had such a tumultuous year last year, brought on mostly by us, but he just had this aura of confidence and calmness. Everyone believed in him.’’

Mattingly, who reached the playoffs in his final playing season with the Yankees in 1995, and was in the postseason six years as a coach with the Yankees and Dodgers, and his last three years as the Dodgers’ manager, immediately conveyed to the players he wasn’t coming to South Beach to work on his tan.

“I didn’t come here to lose,’’ Mattingly said. “I knew the talent they had, and it was just getting them to believe in themselves. We wanted to be relevant all season.

“The second half, that’s when it gets fun, and we feel like this is our time.’’

And, oh, has it been a long time. Their last playoff berth was in 2003 when they won the World Series. And it has been six years since they’ve even had a winning record.

“Our fans deserve to see a winning team in Miami,’’ Samson said. “Miami loves events. We got the All-Star Game next year, but we want to make sure we put on some events before then.’’

Yes sir, after a change-of-address, a name change, and 10 managerial changes in the last 10 years, the Marlins are talking playoffs.

“This has been such a huge difference,’’ said Giancarlo Stanton, the Home Run Derby champ who has played for 10 managers in seven seasons. “Really, I’ve been able to make my offseason plans at the All-Star break every single year.

As balls fly away, the home run hitter again takes leading role in MLB

“All of the offseason work you put into it, you don’t want to do it for just half a season. You look forward to pushing your limits, and seeing what you could do for a season that matters.

“This year, could be that special year.’’

Was Stanton, who’s in the second year of his 13-year, $325 million contract, a believer the moment Mattingly walked through the door?

“No,’’ said Stanton, who hit two doubles and scored two runs Sunday, “not at all. I’ve had the same run-around six or seven times, so I just wanted to see how it played out.

“Hey, so far, so good.’’

The Marlins no longer have to answer questions about why their manager, Mike Redmond, was fired 38 games into a season. Or why he was replaced by Dan Jennings, the Marlins’ GM, only to be fired as manager and GM at the season’s conclusion.

Tranquility suits these Marlins.

“It’s definitely different around here,’’ said left fielder Christian Yelich, who’s hitting .318. “We knew we had a good club last year, but stuff didn’t go our way with the injuries, and all of the off-the-field stuff. Now, with Donnie and our coaching staff here, it really helps.

“We’ve got a confident group here, and our best baseball has yet to come.’’

This is a team that not only survived Stanton’s career-worst slump, a month-long stretch in which he hit .118 with a .206 slugging percentage, but has also played without second baseman Dee Gordon, their 2015 All-Star, Gold Glove winner, batting champion and stolen base leader. He was suspended 80 games on April 29 for performance-enhancing drug use.

Gordon is scheduled to begin his 10-game rehab assignment Monday at Class AAA New Orleans, and will be reinstated July 28. Yet, after that, the Marlins say, it will be tricky. You see, under the new rules, Gordon is ineligible for the postseason. And Derek Dietrich has batted .295 with a .385 on-base percentage in Gordon’s absence.

“That’s something we’ve talked about a lot,’’ said Michael Hill, Marlins president of baseball operations. “There’s been a rhythm going on without him, and now you have to reintroduce him to that, and get him comfortable in that surrounding again. I believe he’ll adjust back in and be fine, but there will be a balancing act.’’

Says Mattingly: “We can’t just toss (Dietrich) aside, and say, “Hey, we’ll call you in a couple of months.’ He’s been too good. If we get to where we’re capable of going, he needs to play.’’

Besides the steady of play Dietrich, there has been the uncanny performance of Ichiro Suzuki, who collected three more hits Sunday, pulling within six of 3,000, and now hitting .347 as their fourth outfielder. And, perhaps their biggest savior has been Realmuto, who’s hitting .314 in his first full season, and leading all catchers with eight stolen bases, while playing steady defense.

“In a couple of years,’’ Marlins bench coach Tim Wallach said, “he’ll be the best catcher in the game.’’

Mattingly also believes that Realmuto will also be their future clubhouse leader, but for now, the torch is in the hands of third baseman Martin Prado, who’s also hitting .322. He kept the clubhouse together during its tumultuous times, and made sure his teammates never quit on themselves, constantly reminding them of their talent.

“Through all of the craziness of last year,’’ Hill said, “you saw young players realizing they could be successful, and Martin Prado was a big part of that culture change. We really felt this talent was on the cusp of doing some great things, and now we feel we have the right leader to get us over the hump.

“There’s no panic in Donnie. No worry. Just a feeling that we’re going to be OK.’’

Normalcy has never felt so good.

Follow Nightengale on Twitter @BNightengale and Facebook