Im going to quickly describe this, as I have to do similar for billboarding of my particles.
Simply, you have your desired target vector (target - viewer), and you have your viewer direction vector. You want your target vector to have no "Z" component effectively (as you are rotating around the Z axis). I eliminate the Z component and normalise the vector. You then cross the 2 vectors to get your rotation axis, Dot the vectors to be able to determine angle of rotation (Acos if i recall). Create a matrix with the axis and the angle. Hope this is what you are after! Let me know.
If it is, I will post my method in c# code.