Usher and his ex, Tameka Foster, have a divorce that's much more acrimonious than amicable -- and their son's near drowning exacerbated their battles over custody of their two boys.

Foster filed an order for emergency primary custody following the drowning scare of their eldest little boy, Usher Raymond V. Foster claimed that Usher is an inattentive father who often leaves his kids with inept caretakers (in this case, his aunt). Usher and his counsel argued that the incident could have happened to anyone.

Usher kept it classy during the proceedings, in which he came out victorious -- even hugging Foster, who's repeatedly attacked him in court and the press following their split.

Still, the troubles may not be over yet. Since Usher was awarded primary custody of the tots, he's still been paying $8,000 a month in child support to Foster ... despite Foster not having the kids often at all. TMZ reports that Usher's requested a hearing, but a date is TBA.

Watch Tameka Foster Testify in Court