Can a letter from a professor not from my university but a high-ranking university carry extra weight? After reading this question, I started wondering about students applying for graduate school and the letters of recommendation accompanying their applications.

Let's say Student is studying at University A and one of his lecturers is primarily working at University B (lecturer was doing some adjunct or other kind of part-time work at University A). University B is a much higher ranked school. After graduation Student asks the lecturer for a letter of recommendation so Student can attend University B. How much extra weight is the letter of recommendation given in the application process if it is from a lecturer at the university?

I would guess that it would depend on how that lecturer's past recommendations have turned out but I'd like to hear from the experts.

Does it change anything if Student wants to become a PhD and would like to have the lecturer as Student's adviser?
Getting a good letter is more important than getting a letter from a professor at University B. So if the professor in question only knows you through your attendance of his course, he most likely won't be able to speak to your research potential. As that is the most important aspect of an application for graduate school, this would not work in your favour. (The points in this answer are excellent guidelines for who to ask for reference letters.)

If he is otherwise qualified to write a good letter for you, then the fact that he is from University B might work slightly in your favour, as admission committees tend to give greater weight to letters of recommendation from researchers that they know.