LGBT and human rights activists erupted in celebration in Quito and the port city of Guayaquil, waving the rainbow flags that symbolize the gay rights movement.
The Constitutional Court said same-sex marriage had been approved in a 5-4 vote of its nine judges in a closed door hearing.
Ecuador, where the church is very influential, thus joins Argentina, Brazil and Colombia in recognizing same-sex marriage.
“It means that Ecuador is more egalitarian,” said lawyer Christian Paula of the Patka Foundation, which provides legal advice for around 10 same-sex couples seeking to marry in the country.
The four dissenting judges argued that in order to recognize same-sex marriage, constitutional reform would have to be debated in the National Assembly. Gustavo Medina, a former Supreme Court president, told AFP that Ecuadoran authorities were obliged to abide by decisions of the Constitutional Court, which were “binding and mandatory.”
Ecuador has recognized de facto civil unions for same-sex couples since 2015.
The Constitutional Court approved same-sex marriage as it ruled on lawsuits by two pairs of men who wanted to wed.
The men in one of those couples are named Efrain Soria and Javier Benalcazar. “I want to say hello to Javier, who is in Guayaquil. Honey, I love you,” Soria told reporters in Quito.
He urged other gays to stop hiding and “enjoy the happiness that comes from being equal, like anyone else.”
Ecuador’s current constitution defines marriage as the union between a man and a woman. The charter, ratified in 2008, also bars same-sex couples from adopting children.
But the judges that approved same-sex marriage said they based their decision on the idea that all people are equal. They also said they sought to counter any kind of discrimination.