In exchange, Osuna agreed to a peace bond, which requires him to not contact the woman he is alleged to have assaulted and to continue counseling. He must comply with the conditions of the bond for one year or face criminal charges, which would carry a maximum sentence of up to four years' imprisonment.
Osuna nodded when Judge Melvyn Green asked if he understood the agreement.
"I am pleased and relieved by today's court decision," Osuna said. "Now I can begin to put these allegations behind me and focus on baseball. I want to thank my family, teammates and fans for believing in me. I am grateful to the Astros for providing me with the opportunity to play baseball and compete for a World Series championship.
"I will make no further comments about this matter, as I plan on moving past this and look only to the future."
The 23-year-old Osuna, then a member of the Toronto Blue Jays, was charged in May with assault in an alleged domestic incident.
The woman Osuna is alleged to have assaulted lives in Mexico and made clear she would not travel to Toronto to testify. Major League Baseball suspended Osuna without pay for 75 games for violating its domestic violence policy.
The Blue Jays later traded him to Houston, and his suspension ended Aug. 5.
Astros general manager Jeff Luhnow acknowledged that Osuna's case had been "a distraction for everybody" since the closer was acquired from Toronto.
"You never know how a legal case is going to get resolved," Luhnow said Tuesday. "We're thankful it's behind us now and we can focus on what's ahead."
Houston, the reigning World Series champion, moved to 100-57 this season with Tuesday night's 4-1 win against Toronto, and clinched its second straight AL West title with Oakland's loss at Seattle.
Osuna needed just six pitches in the ninth for his 20th save in 21 chances. He was booed by Blue Jays fans for the second straight game, starting with when he entered and then in between pitches.
Speaking through a translator, Osuna said he was untroubled by the negative reaction.
"When I came into the game I was focused on what I had to do, so it didn't affect me,'' he said.
Earlier Tuesday, the Astros issued a statement saying they "look forward to Roberto continuing his commitment to be a productive and caring part of our community."
"The Astros remain committed to increase our support regarding the issues of domestic violence and abuse of any kind," the statement continued. "We have engaged with a number of local, state and national organizations -- and we look forward to working with them in the short term and over the long term."
Osuna was greeted by boos Monday when he entered in the ninth inning in the Astros' win over the Blue Jays, the first time he had returned to the Rogers Centre since being traded.
Osuna's attorney, Domenic Basile, said the player had planned to plead not guilty had the matter gone to trial.
"I wish to make it clear that this is not an admission of criminal or civil liability," Basile said Tuesday. "He is content to enter into the peace bond (and) is aware of the conditions and will abide by the conditions."
The Associated Press contributed to this report.