Minor league pitchers Hector Perez, 22, and David Paulino, 24, also are headed to Toronto in the deal. Paulino had been Houston's No. 3 prospect, according to MLB.com, before his 80-game suspension last season for a performance-enhancing-drug violation; he has since dropped to No. 23. Perez is the Astros' No. 10 prospect, according to MLB.com.
Osuna, 23, is eligible to pitch in the big leagues starting Sunday after a 75-game suspension under Major League Baseball's domestic violence policy. He has made six scoreless one-inning appearances in the minors since July 14, the last three at Triple-A.
Osuna has not pitched in the majors since May 6, two days before he was put on administrative leave when he was charged with one count of assault in Toronto -- a case that remains pending. His next court appearance is Wednesday.
"This has been exceptionally difficult," Blue Jays general manager Ross Atkins said on a conference call. "... This was a negotiated agreement between Major League Baseball and the players' association."
Said Astros pitcher Justin Verlander: "It's a tough situation. I think the thing for us to remember here is that the details haven't come to light. We don't know the whole story. Obviously, I've said some pretty inflammatory things about stuff like this in the past, and I stand by my words.
"But I think with an ongoing case, as is this one, just see what happens. But it will be interesting. I think he plans to talk to us when he gets here, and we'll go from there and see what happens."
In March, Verlander strongly criticized former Detroit Tigers prospect Danry Vasquez on Twitter after video surfaced of him allegedly assaulting a woman.
The Astros held a team meeting before Monday's game at Seattle that was "about us keeping a winning mindset and not letting distractions get in the way," Verlander said. "We don't know the details of much. I haven't really paid attention to [Osuna's case], for obvious reasons; it wasn't really in my life. Now it is.
"That's probably going to be a personal thing that stays in the locker room and won't be talked about publicly, as those things are."
Osuna is 0-0 with nine saves and 13 strikeouts in 15⅓ innings this season, following an All-Star 2017 season in which he went 3-4 with 39 saves and a 3.38 ERA.
The right-hander will pitch in another minor league game this week before joining the reigning World Series champions on Sunday.
He would be eligible to pitch in the postseason, unlike players suspended under the drug policy this year, such as Mariners second baseman Robinson Cano.
Osuna lost 89 days' pay, which comes to $2,536,022 of his $5.3 million salary, and the suspension delayed his eligibility for free agency by one year until after the 2021 season.
"We are excited to welcome Roberto Osuna to our team," Astros general manager and president of baseball operations Jeff Luhnow said in a news release. "The due diligence by our front office was unprecedented. We are confident that Osuna is remorseful, has willfully complied with all consequences related to his past behavior, has proactively engaged in counseling, and will fully comply with our zero tolerance policy related to abuse of any kind.
"Roberto has some great examples of character in our existing clubhouse that we believe will help him as he and his family establish a fresh start and as he continues with the Houston Astros. We look forward to Osuna's contributions as we head into the back half of the season."
In a statement released by Houston, Osuna said: "I am excited to join the Houston Astros and move forward with a fresh start to my career. The positive character of my new teammates is a big reason for their success and I look forward to bringing a positive contribution to this great group of guys as we work towards many more winning seasons. I thank Jeff Luhnow and the entire Astros organization for believing in me -- I will not let them down."
Osuna had been the Blue Jays' closer since 2015.
Giles, 27, is 0-2 with 12 saves and a 4.99 ERA in 30⅔ innings this season and was in the minors.
He punched himself in the face this season while heading to the dugout after giving up a three-run, ninth-inning homer to the New York Yankees' Gary Sanchez on May 1. He was optioned to Triple-A Fresno on July 11, a night after the hard-throwing righty appeared to curse at manager A.J. Hinch when he lifted Giles from the game.
Atkins said Giles has shown "he's willing to be accountable for those actions."
"It's unfortunate," the GM said. "I'm sure that contributed to him being available."
"The due diligence by our front office was unprecedented. We are confident that Osuna is remorseful, has willfully complied with all consequences related to his past behavior, has proactively engaged in counseling, and will fully comply with our zero tolerance policy related to abuse of any kind."Astros GM Jeff Luhnow
Giles had 34 saves in 38 chances with a 2.30 ERA and 11.9 strikeouts per nine innings for the Astros last season. In the postseason, however, Giles allowed two runs in three innings against the Boston Red Sox in the American League Division Series. He surrendered three more runs in the ALCS against the Yankees, taking the loss in Game 4, and he allowed five runs in a pair of World Series appearances against the Los Angeles Dodgers.
Giles entered Game 4 of the World Series in the ninth inning with the game tied at 1 and allowed all three batters he faced to reach base. He took the loss and did not appear again in the series.
He has a $4.6 million salary and is eligible for free agency after the 2020 season.
Paulino is 2-1 with a 6.25 ERA in nine games with the Astros this year and has a 4.67 ERA in seven games for Triple-A Fresno and the rookie-level Gulf Coast League Astros.
Perez is 3-4 with two saves and a 3.73 ERA in 21 games at Class A Buies Creek and Double-A Corpus Christi.
"This made sense for the organization from a baseball perspective," Atkins said. "We had the opportunity to trade Roberto for three players we're excited about."
The Associated Press contributed to this report.