In the middle of all that, they made a trade to bolster their bench and went on to beat the hottest team in baseball.
Fernandez improved his career home record to 27-2 and set a franchise record for single-season strikeouts, leading Miami to a 3-0 win over the Kansas City Royals on Wednesday night.
"I was cramping for the last five pitches," said Fernandez, who said he was fine postgame. "I was cramping, cramping, sweating and sweating."
In the end, Fernandez made the Royals sweat, breaking the reigning World Series champions' nine-game winning streak.
During the game, Miami swung a deal to acquire Jeff Francoeur from the Atlanta Braves. The Marlins, who did not surrender any major-leaguers in the trade, will have to make a move Thursday to create roster room for the veteran outfielder.
Francoeur, 32, has 160 major league homers and will be used in a reserve role.
"Once the (groin) injury to (right fielder Giancarlo Stanton) happened, we wanted to get a right-handed outfielder," Marlins general manager Michael Hill said. "He wanted someone who could give us punch against left-handed pitching.
"As well as our team has played, we wanted to do anything we could to get us to where we want to be, which is October baseball."
Fernandez (13-7) set his personal best with his 13th win. He also finished the game with 213 strikeouts this year, breaking the Marlins' previous record of 209 set by Ryan Dempster in 2000.
"Today was an improvement," said Fernandez, who snapped a personal three-game losing streak.
Fernandez allowed six hits and two walks while striking out nine in seven scoreless innings. He threw 111 pitches, his most since May 26.
A.J. Ramos and Fernando Rodney preserved the shutout by pitching one inning apiece.
Rodney, who earned his 25th save of the season, got help from shortstop Adeiny Hechavarria, who made a sensational diving catch on an Alcides Escobar line drive for the first out of the ninth.
"That was a great play," Escobar said. "That changed the game right there in that situation."
The Royals (65-61) were not done, though. They loaded the bases with two outs against Rodney, who got out of his own jam by getting Christian Colon to line out, again to Hechavarria but more routinely this time.
Marlins manager Don Mattingly said Ramos, who had been the closer for most of the season before getting hurt and surrendering the job to Rodney, is fine with being used in the eighth inning.
"A.J. wants to be a closer, but, more than that, he wants to win," Mattingly said. "He wants to do what it takes for us to win, and that's huge."
Aside from his stellar pitching, Fernandez went 2-for-2 as a hitter, raising his batting average to .286.
His one-out single in the sixth started a three-run rally for Miami (66-60). Dee Gordon and Martin Prado followed with singles, and Christian Yelich, up with the bases loaded, lined a two-run single to right to raise his team-leading RBI total to 74.
Marcell Ozuna capped the rally with a sacrifice fly, which was caught by Alex Gordon in medium-range left field. Gordon threw accurately to the plate, but Prado was able to slide away from catcher Salvador Perez's tag.
Royals right-hander Dillon Gee (5-7), who started the game with five scoreless innings, was charged with all three runs in the sixth and took the loss. He lasted just 5 1/3 innings.
Gee said the single by Fernandez that started the game-winning rally was well-struck.
"That may have been the hardest-hit ball I gave up all night," Gee said. "He can swing the bat a little bit."
NOTES: The Royals' bullpen ran its franchise record of consecutive scoreless innings to 34 2/3. The previous record of 29 1/3 innings was set in 1969. ... Marlins CF Marcell Ozuna, who left the Tuesday game due to a family emergency, was back in the lineup Wednesday. Ozuna said his wife, who is six months pregnant, wasn't feeling well but is now fine. ... Marlins RF Ichiro Suzuki went 1-for-3 and needs one more hit to tie Wade Boggs (3,010 hits) for 27th place on the major league all-time list. ... LHP Braxton Garrett, Miami's first-round pick (seventh overall) in June out of an Alabama high school, won't pitch again this year. He isn't hurt, but the Marlins are being conservative with such a young pitcher. ... Marlins LHP Wei-Yin Chen, on the disabled list since July 20 due to an elbow injury, threw a bullpen session Wednesday, his first since getting hurt.