Stern and Gerlach used neutral particles: hot silver atoms from an oven. Lorentz force (experienced by atoms) due to an eventually uniform field should be globally zero. So the net force acting on atoms must be another: atom is a coil-like system and what they did is to dealing with it as with the induction coil you find in an analogical multimeter.
You obtain a force just for a non-null derivative of magnetic induction, that is F=gbB where:
g is the coupling constant between angular momentum and magnetic dipole momentum
B is your field
b is there because I supposed B=a+bz along the non-uniform axis.
Stern and Gerlach knew the presence of an magnetic momentum for atoms also before the experiment, but they obtained its quantization by showing it with astonishing facts!