Forgive me in advance for my nomenclature, I'm sure there are specific terms for the things I'm about to describe, but that's part of the reason I'm here. I'm not hugely skilled in geometry and if I knew the proper terms I'd probably be able to find the answer myself.
Consider the following object I've mocked up digitally:

It's comprised of the thicker cylinder, which I'll call A and the thinner cylinder which I'll call B. These cylinders actually represent lines, so their thickness isn't important, but depicting them this way helps me think. In my application, I'm considering B as an offshoot, coming off of A.
The ground plane is also visible here and is relevant. A is "pocking through" the ground at an angle. And the intersection point of A and B is on that plane.
Here is my task. I need to line up the center of B so that it is aligned with the ground plane, but only by rotating the entire object along the central axis of A. No other rotation/translation.
The end result would look like this:

My problem is I need to determine the angle of rotation needed around A to align B with the ground. And well... I can't figure out how to do that. I can intuit that because A and B intersect on the plane, that there must be exactly two correct angles (provided the angle between A and the ground is greater than 0 and lesser than 90, which we can assume for this).
I have both A and B as 3D vectors. Mathematically, how can I calculate the angle around A I need to rotate B so that it aligns completely with the ground plane (where the vertical aspect of the B vector would be 0)? I might not need exact formulas so much as a general procedure, we'll see.

Treating the cylinders as vectors as you say, let's call $O$ the intersection point between $\vec{A}$ and $\vec{B}$ on the ground plane, and $\vec{C}$ the final version of $\vec{B}$ after it has been rotated. We want to find the angle between $\vec{B}$ and $\vec{C}$, which can be calculated as, $$\theta = \cos^{-1} \left(\frac{\vec{B} \cdot \vec{C}}{||\vec{B}|| \; ||\vec{C}||}\right) \tag{1}\label{eq1}$$
So we need to find $\vec{C}$. We know $\vec{C}$'s tail is at $O$, since we are rotating about $\vec{A}$. We also know 1) $\vec{B}$ and $\vec{C}$ should have the same length, 2) the dot product with $\vec{A}$ should be the same since we are rotating about $\vec{A}$, and 3) $\vec{C}$ lies in the ground plane (since both the tail and centre lie in the ground plane, the whole vector lies in it). This gives us 3 equations on the three unknowns for direction components of $\vec{C}$, $$ ||\vec{C}|| = ||\vec{B}|| \\ \vec{C} \cdot \vec{A} = \vec{B} \cdot \vec{A} \\ \vec{C} \cdot \vec{e}_z = 0 $$
This should be solvable by hand (though the expressions may get ugly), and then you can plug into Eq. \eqref{eq1}.