Detailed information about rules and conditions for entering Estonia can be found on the website of the Estonian Police and Border Guard Board.
According to the Estonian Aliens Act, a long-stay (D) visa can be applied for in a number of circumstances such as study, work or family relations. Person can apply for a D-visa if it is proved that the need to stay in Estonia is more than 90 days in 180 day period. D-visa may be issued for the period of stay of up to 365 days within twelve consecutive months.
D-visa can be applied from any Estonian representation. Full list of Embassies handling visa applications can be found here. Applications are examined and decided within 30 days from the date of lodging.