It would work in a vacuum, so I'll simplify by assuming no air resistance.
When the ball is hit, it spins in a certain direction, for example to hit the ball so that it would follow this path:

requires the ball to be hit along the red arrow, but spinning in the direction of the blue arrow:

The red arrow here is pointing the same way as the initial direction of the dashed black arrow on the first picture.
As the ball travels forward it is "slipping" on the table. This means that the ball is moving over the table but it is rubbing past, not rolling smoothly, like a car skidding to a stop.
The rotation of the ball will slow down as it travels but so will the ball's speed, so initially it will look like this:
$$ F_\mathrm{net} = -\mu_k N $$
where $ \mu_k $ is the coefficient of kinetic friction and is lower than $ \mu_s $ which is the coefficient of static friction. N is the normal force (in this case equal in magnitude to $mg$)
The force is in the negative direction, meaning the ball is slowing down (I've taken positive to be the direction it initially travels in (the direction of the red arrow)) so at some point the ball will stop moving completely. At this point, if the ball is still rotating, there will still be a resultant force on the ball:
$$ F_\mathrm{net} = -\mu_k N $$
so the ball will start moving in the negative direction. Some short time later the ball will stop slipping and continue to roll, with no resultant force, and therefore no net acceleration, but in a different direction to the direction it was hit.
The three graphs below might be useful to understand the motion of the ball further. The first graph shows the position of the ball, the second graph shows the first derivative of position (velocity) and the third graph shows the second derivative (acceleration). The time $t'$ denotes the point at which the ball stops slipping and starts rolling smoothly.
