AllThings12thMan,
The answer to your question depends on the level of play.
mAgnoliAg & others,
I'll refrain from personal comment, but the NBA is an exception to High School, College or International rules. I'm giving you rules as I played and officiated under (which was not NBA). I will leave you with this example of NCAA & High School Rules:
https://www.youtube.com/watch?v=C7kwF2NvtdYYou will find in the comments section:
A correct call on a backcourt violation in a Big 10 conference game between Purdue v. Michigan on January 24, 2013. Even though the defense deflected the ball, a deflection by the defense does not end team control rules under NCAA or NFHS rules. The offensive player was the last to touch the ball before it went into the backcourt, and was the last to touch the ball after it went into the backcourt.
The requirements for a backcourt violation call include;
1. Team control (and player control when coming from a throw-in)
2. Ball gains a frontcourt status
3. Team in control is the last to touch the ball while the ball has a frontcourt status.
4. Team in control is the first to touch the ball after the ball gains backcourt status.
NOTE: Under NBA rules, team control ends with the defensive deflect the ball, hence the reason the offense can retrieve the ball, even if it deflects off the offense before it heads into the backcourt. THIS IS DIFFERENT UNDER NFHS AND NCAA RULES.