Mn3Ga bulk material and thin films deposited on several different substrates have been investigated using x-ray and neutron diffraction, x-ray absorption spectroscopy, x-ray magnetic circular dichroism, and electronic structure calculations using density-functional theory with the aim of determining the atomic site occupancy, magnetic moments, and magnetic structure of this tetragonal D0(22)-structure compound. The Mn3Ga has close to ideal site occupancy, with Ga on 2a sites and Mn on 2b and 4d sites. The magnetic structure is basically ferrimagnetic, with the larger Mn moment of about 3 mu B on the 2b site, which is coordinated by 8 Mn 4d and 4 Ga, and the smaller one on the 4d site, which is coordinated by 4 Mn 2b, 4 Ga, and 4 Mn 4d. The Mn d-band occupancy is close to 5 on both sites, and the orbital moments are small, <0.2 mu B. The material nevertheless exhibits substantial uniaxial anisotropy, K-u = 1.0 MJm(-3), which originates from the 4d site. The 2b site has hard axis anisotropy, which together with an oscillatory exchange coupling from the first and second nearest neighbors, leads to a soft component of the magnetization in the c plane, coexisting with c-axis hysteresis loops exhibiting coercivity of up to 1.2 T, and magnetization in the range 110-220 kA m(-1) at room temperature, depending on preparation conditions. Tetragonal Mn2Ga films behave similarly. Manganese is lost from both sites, but the films have substantially larger magnetization (480 kA m(-1)) and anisotropy constant (2.35 MJm(-3)) than Mn3Ga.