There's only so much space on the baselines in basketball, so it's rare for any shot to come from behind the basket. But it does happen, and each level of basketball as its own set of rules to determine if the shot counts.
National Collegiate Athletic Association
The NCAA rule for shooting over the backboard states, "The ball shall be out-of-bounds when any part of the ball passes over the backboard from any direction." This means a college player can't score on such a shot even if the ball makes contact with the basket support or the back of the unit. If it does, it's an automatic turnover.
National Basketball Association
The NBA waves off any shot that travels over the top of the backboard from behind the basket unit. However, it can count if a player working the baseline sinks a shot that went over a segment of the backboard. NBA legend Kobe Bryant showcased a premier example of the rule exception in 2009 against Oklahoma City. He drove the lane, but defensive pressure forced him behind the bucket. Despite his momentum pushing him toward the baseline, Bryant launched a high-arching shot that flew directly over the basket supports and into the hoop.
International Basketball Federation (FIBA)
The International Basketball Federation features a rule that distinctly differs from the NBA and NCAA. A player can plant his feet behind the basket without driving to the hoop and legally deliver a shot that passes straight over the backboard. It's only disallowed if the ball touches the basket support, or if the player steps on the baseline.
Several famous shots have come from the other side of the hoop, but perhaps none more so than one from Hall of Fame forward Julius "Dr. J" Erving. Back in the 1980 finals, the 76ers star took off from behind the backboard and went around several Los Angeles Lakers to deliver a clutch reverse layup. Some people consider it the greatest shot in NBA history.