The residence permit entitles the holder of this title to stay in Germany. It is generally issued for a limited period of time and for a special purpose. The necessity to apply for a residence permit depends on the country of origin and the intended period of stay in Germany. The responsible institution for the issue of a residence permit is the Immigration Authority at the respective location in Germany.
Each foreigner coming from a "third party country" who stays in Germany longer than three monts is required a residence permit. Citizens from EU- or EEA-member countries as well as from Switzerland are exempted from this obligation. In the case of visa obligation for your country of origin, the possession of a German visa ("D-visa") is a mandatory prerequirement for being entitled to apply for a residence permit in Germany.
After arrival in Germany, you have to register within 14 days at the Citizens' Registration Office of your respective location of stay. At Chemnitz, the responsible institution is the Bürgeramt (Meldebehörde). A certificate of registration is not only a mandatory requirement for applying for a residence permit but also i.a. for opening a bank account at a German bank.
Your central point of contact regarding all residential issues is then the local Immigration Authority. To there you have also got to submit your application for a residence permit. In this context, you have to fill in the respective application form and to send it to the Immigration Authority either via mail (Düsseldorfer Platz 1, 09111 Chemnitz) or you put it in the mailbox installed in the building for this purpose (Düsseldorfer Platz 1, 3rd level, next to room no. 3.032).
The issue of the residence permit (in the form of an electronic chipcard) happens finally within a personal appointment. The date will be told to you by the Immigration Authority (for this purpose you should read regularly the emails in the account that you have indicated as contact in your application). You can download a list of the documents which you should bring with you to that appointment here. In the time between the application and the issue of the residence permit, it is also possible to stay in Germany with your visa. The fees for the issue of a residence permit amounts currently 110 Euro, for its prolongation 80 Euro.
The residence permit is issued exclusively for the purpose of stay you applied for (i.a. PhD-studies, employment, family reunion). In the case that this purpose of stay changes, you have got to immediately submit a new application because this change of purpose might turn your existing residence permit invalid and in that case you would be illegally staying in Germany which is considered as criminal offence. In case you would like to take up an employment, you should firstly check if this is explicitly permitted in the ancillary clauses of your residence permit (supplementary sheet). An overview of the different residence permits for researchers may be downloaded here.
These indications should serve as first general orientation. With regard to the respective individual circumstances of each stay as a foreigner in Germany and the corresponding legal regulations, particularly when coming from a "third-party country", it is strongly recommended to get in touch with the responsible Immigration Authority as soon as possible in any case.