Vietnam's National Assembly on Tuesday unanimously passed the law passed week.
The law comes into effect on 1 January 2017, and officials are in the meantime working out the details.
According to the Standing Committee of the National Assembly, the law was passed to "meet the demands of a part of the society in accordance with international practice and not counter to the national tradition."
The law will effectively make it legal for hospitals to offer gender reassignment surgery. At the moment many travel overseas for the procedure.
A celebration of around 100 people from the LGBT community took place in the capital city, Hanoi.
"I called my mother and my older sister, who have been my biggest supporters, and they cried too," Le Anh Phong told the BBC at the celebration.
Gay and transgender activists in Vietnam say a new law recognizing their rights will pave the way for gender reassignment surgery in the communist country and reduce discrimination.
However, as the legislation only affects those who have undergone sex change procedures, it is of no benefit to transgender people who have not had surgery.
"This is an important and most welcomed first step," says Tran Khac Tung, director of ICS Vietnam, a LGBT awareness and support organisation based in Ho Chi Minh City.
According to ICS, there are around 270,000 transgender people in Vietnam.