How do internal fellowships work? Most graduate students in the USA work as lab assistants or teaching assistants. But some people have fellowships from the school just to study. I know you probably need a very good GPA and GRE to get a fellowship. What else does a department look for to decide about who gets a fellowship? Does it help if you have a masters degree?
At the university where I work, we have two types of internal fellowships for graduate students. 

The first type are funded by donations to the university foundation with instruction that the funds are to be used to support graduate students studying in a specific department (and sometimes, studying a specific subfield, etc). These fellowships are typically small awards that are used to provide extra funds to outstanding students that are otherwise funded by research or teaching assistantships.

The second type are similar to the first in that they are again small awards used to provide extra funds to outstanding students. However, they are funded and administered at the university level. Each department can nominate some students annually for these awards, typically in proportion to the number of doctoral students working in the department. Award decisions are typically finalized by a university-wide director of graduate programs.

Other schools also sometimes have a third type, again funded and administered at the university level. Large donors can fund full fellowships for graduate students that cover all tuition and also provide a stipend; these fellowships replace a teaching or research assistantship entirely, and allow the student and advisor to conduct research on a topic of their choice. Typically very few such fellowships are available, but again individual departments nominate students.

In each of these cases, fellowships are typically awarded to applicants to doctoral programs at the time of admissions and are designed to attract the very best students to the university. Therefore, all dimensions of an outstanding graduate application are likely to help you win a fellowship when available!