ARLINGTON, Texas - With Cole Hamels, the Texas Rangers have gotten another ace in hopes of getting back to the playoffs — in 2015 and beyond.

Texas obtained the Phillies left-hander in an eight-player deal completed before Friday's non-waiver trade deadline after being agreed on earlier in the week.

Lefty Matt Harrison and five prospects are going to Philadelphia. Texas also got left-handed reliever Jake Diekman and will receive $9.5 million — $7 million in 2016 and $2.5 million in 2018 — to offset part of the contract for Hamels, who is due $22.5 million per season through 2018 with a club option for 2019.

"I'm excited to start the next chapter of my baseball life," Hamels said. "They have a lot of great players and there's always a chance in that league. I don't think they are too far away, even this year."

Hamels, the 2008 World Series MVP, is the first pitcher in major league history traded during a season immediately after throwing a no-hitter — he no-hit the Chicago Cubs last Saturday at Wrigley Field.

With a slight smile, Texas general manager Jon Daniels said he was watching that game and "rooting for a couple of runs, maybe a bloop hit here or there, just from the standpoint of trying to make the deal happen."

The Texas debut for the three-time NL All-Star will be Saturday night at home against the San Francisco Giants. Hamels is 6-7 with a 3.64 ERA in 20 starts this season.

"You're talking about one of the best pitchers in the game, under control, who wants to be here," Daniels said. "Work ethic, consistency, performance, the fact that we were able to structure the deal as we did. And made it financially work for us. That was a big piece."

Along with Harrison, the Phillies got Double-A catcher Jorge Alfaro, outfielder Nick Williams and right-hander Jake Thompson — three of the Rangers' top prospects — and Triple-A right-handers Jerad Eickhoff and Alec Asher.

"We were looking for depth and talent and we got both," Phillies general manager Ruben Amaro Jr. said.

Hamels, who had a limited no-trade clause, vetoed a deal to the AL West-leading Houston Astros.

"You don't want to say no to anybody and you don't want to let a city down or an organization down," Hamels said. "But you want to do what's best not just for my baseball career, but for my family."

Texas (49-52) went into Friday night's game against the Giants in third place in the AL West, eight games behind Houston. The Rangers were four games behind the second AL wild-card spot, with five other teams between them and the top two spots.

The rebuilding Phillies were a big league-worst 39-64.

Hamels next year will be part of a rotation that expects back Japanese ace Yu Darvish, who had Tommy John elbow ligament replacement surgery in March. Left-hander Derek Holland, who pitched only one inning the April 10 home opener, on Thursday began his minor league injury rehab from a strained shoulder.

The 31-year-old Hamels was drafted by the Phillies 17th overall in 2002, and is 114-90 with a 3.30 ERA over 10 big league seasons. He was an integral part of the greatest run in franchise history when they won five straight NL East titles, two pennants and one World Series from 2007-11, going 7-4 in post-season games.

"It was worth everything," Hamels said about playing in Philadelphia. "It gives you a way to fight even harder . to hear the cheers, and you understand the boos."

Hamels has three years remaining in a $144 million, six-year contract, a deal that includes a $20 million club option for 2019 or a $6 million buyout. That option becomes guaranteed at $24 million if he throws 400 innings or more in 2017-18, including at least 200 in 2018, and isn't on the disabled list at end of 2018 with left shoulder or elbow injury.

Diekman is 2-1 with a 5.15 in 41 appearances this season. After 191 games for the Phillies since 2012, he was in a Texas uniform and active for Friday night's game.

The 29-year-old Harrison, a 2012 All-Star, has made three starts this season after having spinal fusion surgery last summer.

Harrison won 18 games in 2012 and then received a $55 million, five-year contract. But he made only two starts in 2013 before two operations on a herniated disk in his back. After four starts in 2014, he was diagnosed with significant nerve irritation and a forward displacement of his vertebrae, known risks after the earlier procedures.

Alfaro, 22, signed as a 16-year-old free agent from Columbia in January 2010, hit .253 with five homers and 21 RBIs in 49 games at Double-A Frisco this season before a left ankle injury.

Williams and Thompson, both 21, were second-round draft picks in 2012. Williams hit .299 with 13 homers and 45 RBIs in 97 games this season at Frisco, where Thompson was 6-6 with a 4.72 ERA in 17 starts.

Philadelphia will pay Texas in 12 semimonthly installments from April through September in 2016 and 2018.

___

AP Sports Writer Rob Maaddi in Philadelphia contributed to this report.