MIAMI -- The Marlins' search for a starting pitcher literally went down to the wire. For weeks, the club had been exploring numerous options, weighing everything from club-controllable arms to high-profile rentals.
Miami was finally able to meet its needs, completing a six-player deal with the Astros that was finalized less than 45 seconds before Thursday's 4 p.m. ET non-waiver Trade Deadline.
The Marlins acquired right-hander Jarred Cosart, outfielder/second baseman Enrique "Kiké" Hernandez and Minor League outfielder Austin Wates from the Astros for prospects Jake Marisnick, Colin Moran, Francis Martes and a 2015 competitive balance Draft pick.
"I think we've always said we're just trying to get better," Marlins president of baseball operations Michael Hill said. "We believe in this club and this clubhouse and we believe in what they're capable of doing. Jarred Cosart will help us win more games and to be a better ballclub, and hopefully that winds up with a playoff spot."
Boosted by a stretch of winning nine of 10, including a three-game sweep at Houston last weekend, the Marlins swung into buy mode by the Deadline.
Before completing the deal with the Astros, the Marlins were in the mix on a number starting pitchers who ended up being dealt on Thursday. Miami had inquires with Boston about Jon Lester. But the club wasn't willing to part with Christian Yelich.
The Marlins also checked in on David Price, John Lackey, Tommy Milone, Wade Miley and Ian Kennedy. There were reports about John Danks, but that was never a serious option.
Dallas Keuchel's name also came up in talks with the Astros, but ultimately, it was the 24-year-old Cosart who was moved to Miami.
"I'm really excited about joining the Marlins," Cosart said. "They have an exciting young group of talent, and it would be great to make a run down the stretch."
Cosart and Hernandez will report to Miami on Friday, with Wates being assigned to Triple-A New Orleans.
The trade enabled the Marlins to address two areas of need. The club has been looking for a starter to add depth to the rotation, which sustained a huge blow when Jose Fernandez underwent Tommy John surgery in May.
Second base is another area the club has been seeking depth. Hernandez can play second and short, but he was used mostly in center field in Houston.
Hernandez offers manager Mike Redmond versatility, plus he has a productive bat. In 24 games with the Astros, the Puerto Rico native was hitting .284 with four doubles, two triples and a homer.
"I know I had talked about the pitcher and the second baseman," Hill said. "But the focus was always about the pitcher. Once you got into discussions with Houston, and they did have a second baseman that you liked, you wanted to try to steer things towards getting what you wanted, especially at the cost of the players that were being discussed."
The trade started off focused on Cosart and Marisnick. When Moran was added to the mix, the additional names were included.
Cosart's arrival means the Marlins will have to figure out which of the starters already in the rotation will go into the bullpen.
The Marlins got a close look at Cosart last Saturday at Minute Maid Park, where he threw 5 2/3 innings of five-run ball. He was supposed to start for the Astros on Thursday night, but was seen hugging teammates and coaches shortly before the trade was made official.
Cosart was 9-7 with a 4.41 ERA in 116 1/3 innings for Houston.
The Marlins expect Fernandez back around the All-Star break next year, and Cosart will be counted on to help solidify the rotation until the young ace returns.
In the eyes of the Marlins, Cosart has high-ceiling potential.
"He has power stuff," Hill said. "Fastball in the mid- to upper-90s. Power slider. I think he will fit nicely into our rotation and definitely in this ballclub. A one-plus, young and controllable starting pitcher that can grow with us moving forward."
Hernandez, who turns 23 on Aug. 24, made his big league debut on July 1.
Before reaching the big leagues, Hernandez lit up the Pacific Coast League when he was with Triple-A Oklahoma City. In 67 games, Hernandez hit .337 with eight homers, 17 doubles and 31 RBIs.
"Versatile piece," Hill said. "I think for Red and his staff, it's very valuable to have a versatile piece. We know Kiké played center field against us. He can play short. He can play second. He can play left. As we got into this knowing we gave up a lot in the deal, we wanted to try to get something valuable to us in return."
Joe Frisaro is a reporter for MLB.com. He writes a blog, called The Fish Pond. Follow him on Twitter @JoeFrisaro.