A lesbian couple became the first to tie the knot in a ceremony that took place just after the new law came into effect at midnight.
The wedding was shown on national TV.
President Carlos Alvarado said the law change meant Costa Rica now recognised the rights lesbian and gay people had always deserved.
He tweeted (in Spanish) that "empathy and love should from now on be the guiding principles which will allow us to move forward and build a country where there is room for everyone".
The first same-sex marriage ceremony was broadcast as the culmination of a three-hour programme celebrating marriage equality.
Marriage equality came about after the constitutional court declared in August 2018 that a ban on same-sex weddings was unconstitutional and discriminatory.
The court gave Costa Rica's parliament 18 months to change the law.
Enrique Sánchez, Costa Rica's first openly gay member of parliament, welcomed the change and praised those who had spent years lobbying for the same-sex marriage ban to be lifted.
"With their experience, their struggles... they have helped build a society where there are no second-class families or second-rate people," he told Reuters news agency.
Same-sex marriage is already possible in Argentina, Brazil, Colombia, Ecuador, Uruguay and some parts of Mexico, but Costa Rica is the first country in Central America to allow it.
Some religious groups had opposed the move and more than 20 lawmakers tried to delay the change in the law.