This is only a partial answer, but:
I'm currently in a PhD program. My university (like many others in the US) doesn't offer a masters program, only a PhD program. The PhD program is structured as follows:
1. Take two years of classes
2. After satisfying course requirements, or somewhere in the middle of this process, find a research group and identify an advisor
3. Advance to candidacy by taking a qualifying exam. This means you're ready to complete your thesis work
4. Do a thesis's worth of research
5. Write your thesis and get a PhD
You can opt to get a masters degree along the way, however, after you've completed a sufficient number of courses. All you have to do is ask the department for it. I think other schools (if they have a masters program) will require you to write a thesis, but it is less than what is expected of a PhD thesis. My understanding is that a masters thesis is kind of a synopsis of stuff people already know whereas a PhD thesis is supposed to be original work that extends a field of research.
Like I said, this is only a partial answer.