Reputation of Masters thesis supervisor I have two options for my masters thesis  (theoretical physics), Professors A and B. A is senior and globally renowned. B is very junior but appears to be making a strong impact in the field. 

When it comes to applying for PhD positions, how important is my supervisor? I'm aware that A giving me a strong letter of recommendation will carry much more weight than B, but I think I'm slightly more interested in B's work. Also, B has told me that if the project is successful it will almost definitely result in a publication. A is not so sure. 

A and B are actually part of the same group. Best case scenario would be having the two of them as joint supervisors. Let's assume that isn't an option and I must choose.
In an ideal world, publishing great research with a renowned professor who writes you an excellent letter of recommendation is the best outcome. However, if you are more interested in Professor B's work, and are more likely to get published, then working with Professor B is almost certainly the better option.

There are several factors to consider here (and more of course, this is just a quick list):


Which professor is doing work I am more interested in?
Which professor will have more time to dedicate to helping me with my research?
With which professor will I be most likely to be published? (This is likely the most important point if your goal is to get into a good PhD program, and follows directly from the first two points)
How well known is the professor?


You should realize that the goal of an admissions committee first and foremost is to determine whether or not you are capable of, and interested in, performing high quality research as a PhD student (and after you graduate). That being said, you want to work with whichever professor will be able to best help them determine that. All that a recommendation from a famous professor really does is add a seal of authenticity to his/her recommendation on your abilities, as they have demonstrated that they are fully aware of the requirements of being a good researcher based on their own body of work. However, that seal of authenticity is typically granted to any professor at a respectable institution. If Professor B is performing well-received, high quality research, then their word will still be trusted by an admissions committee.

With that being said, if you think you'd be able to do great research and get published with Professor A (and are interested in his/her work) then that's probably your best bet. If, however, you are more likely to do great research and get published with Professor B, then that is almost certainly the better option. There's really on better indicator to an admissions committee of your abilities as a researcher than being able to point to your own publications. In fact, if you're able to do this, your application would almost certainly dominate other students who had not performed research / been published, but had received letters of recommendation from well known faculty.

Two last points that are worth mentioning:


You should assume that letters of recommendation of the form: "This student did well in my class" are essentially useless in a PhD application. These are often called DWIC (Did Well In Class) letters in admissions committee circles, and from my understanding, they are typically completely ignored (the committee already has your transcript, so these letters don't tell them anything they don't already know). On the other hand, a letter of recommendation saying, "This student demonstrated an ability and interest in performing high quality research, and would almost certainly be successful as a PhD student" are very valuable in a PhD application.
As user2390246 mentioned, famous professors often don't have time to work directly with master's students. If this is the case, then you're probably better off working with Professor B. Working directly with a professor is very valuable, as they can fill in background knowledge needed during your research, point you in the right direction based on your interests, and perhaps most importantly, show you how to perform great research by example. Of course, they'll also be able to write a more detailed letter of recommendation for you, as they'll have witnessed your strengths and talents first hand.