I've been thinking about a similar issue. In principle, you can do what you want. The magnetometer gives you 3 measurements but their absolute scale is not known. If you have accurate knowledge of the magnetic vector (magnitude and angle of inclination) at your location, that allows you to scale the three measurements, leaving two independent values and an absolute indication of North. Obviously, you can't determine the rotation about the magnetic vector, but I believe that the remaining information is in principle enough to determine the other two angles.
I have not had time to work out the math, although I don't think it is very hard, nor have I done any on line research into the problem. However, if you have found a couple of links that seem promising, post them and I'll take a look.
In any case, a great introduction into the math of creating a 3D compass (which uses a magnetometer and compass) is Freescale's AN4248. Most of it is applicable to the problem. Google "freescale an4248" and it is the top hit.
Edit: for the most accurate magnetometer and resulting angular measurements, you will definitely need to calibrate the magnetometer. It is relatively easy to do. My favorite procedure is described here: Sailboat Instruments: Improved magnetometer calibration (Part 1)