Prime Minister Kaja Kallas says the new legislation will take effect next year.
The Estonian parliament has voted to legalise same-sex marriage.
The move comes just two months after the country's new liberal coalition government took office, and nine years after the country voted to introduce same-sex civil unions.
In April, Prime Minister Kaja Kallas promised to legislate for same-sex marriage "as fast as possible".
“Everyone should have the right to marry the person they love and want to commit to. With this decision we are finally stepping among … all the rest of the democratic countries in the world where marriage equality has been granted,“ Kallas said in a statement.
“This is a decision that does not take anything away from anyone but gives something important to many. It also shows that our society is caring and respectful towards each other. I am proud of Estonia,“ she said.
"We are proud to become the first Baltic country to legalize same-sex marriage," the Minister for Foreign Affairs, Margus Tsahkna, added.
During a vote in the Estonian parliament, the Riigikogu, 55 members of parliament voted in favour and 34 against.
Parliament's measure was tied to a confidence vote on Prime Minister Kaja Kallas’ centre-right government, which has been under pressure from conservative opposition parties and civil society groups to maintain what they say are traditional family values by rejecting same-sex marriage.
Same-sex marriage will become legal in the country on New Year's Day of next year.
Attitudes to same-sex marriage in the country have changed dramatically since 2012, according to the Estonian Human Rights Centre.
It found that 53% of Estonian people currently support marriage equality. This is up six percentage points from two years ago, and a sharp increase from 2021 when just 34% of Estonians supported it.
Speaking to broadcaster LRT a week ago, the president of Estonia's parliament, Lauri Hussar, referred to opinion polls showing a change in attitude but also suggested the war in Ukraine was a contributing factor.
"I think the mood has changed also, because of what happened in Ukraine, because the war brought us to the real problems and what is really important for us," he said.
"It united us in helping Ukraine and also brought us to the roots of liberal democracy and therefore, I think it brought us to think about what is important for us as a society.”
He acknowledge that there remained opposition among "the church and the conservatives", but pointed to other countries, stating: "I want to point out one very interesting thing, that in every society where same-sex marriage has been legalised, it hasn’t been any issues anymore, because the issue has been closed and the society moved forward."