If you attend to stay in Hungary more than 90 days, you shall apply for a residence permit.
The competent authority is the National Directorate-General for Aliens Policing (Országos Idegenrendészeti Főigazgatóság, former Office of Immigration and Asylum). (http://bmbah.hu/index.php?lang=en)
An application for residence permit may be submitted at the consulate of Hungary located in the country where the applicant’s permanent or temporary residence is located, or in the country of the applicant’s nationality.
Apart from the submission of applications at Hungarian diplomatic mission as a general rule, Hungarian law also provides the possibility of submitting such applications in Hungary as well. Third-country nationals residing in the territory of Hungary may submit an application for residence permit at the regional directorate responsible for the place where the place of accommodation of the third-country national is located, if there are special circumstances to justify submission of the application in Hungary, or if lawfully residing in the territory of Hungary as a national of the States listed in Annex II of Council Regulation 539/2001/EC, or together with such third-country national in the capacity of a family member. The special circumstance referred to above shall, in particular, cover any event related to medical treatment, family reunification or occupational activity that has occurred for reasons beyond the third-country national’s control, and that prevents to have the application submitted at a place normally prescribed under general provisions set out by law.
Residence permit for the purpose of study (http://bmbah.hu/index.php?option=com_k2&view=item&layout=item&id=70&Itemid=824&lang=en)
Residence permit for the purpose of employment (http://bmbah.hu/index.php?option=com_k2&view=item&layout=item&id=62&Itemid=816&lang=en)
Residence permit for the purpose of family reunification (http://bmbah.hu/index.php?option=com_k2&view=item&layout=item&id=54&Itemid=808&lang=en)
Residence permit for other purposes (http://bmbah.hu/index.php?option=com_k2&view=item&layout=item&id=57&Itemid=811&lang=en)
When the application is submitted, the applicant’s facial likeness and – over the age of six years – fingerprint will be taken for the residence permit issued with biometric data.
If the decision of the regional directorate is in favour of the application for residence permit, it shall constitute approval for the issue of an entry visa for receiving a residence permit, of which the competent consulate officer shall be notified. The entry visa for receiving a residence permit shall be issued by the competent consulate officer based on the regional directorate’s decision.
Moreover, please note that D visas for entitlement to receive a residence permit issued to third-country nationals are single-entry visas authorising a stay of not more than 30 days, therefore we recommend to visit the regional directorate of the National Directorate-General for Aliens Policing responsible for the place where their future accommodation is located as soon as possible after entering Hungary in order to receive the residence permit and register such Hungarian accommodation.