Argentina legalized same-sex marriage July 15.
The vote in the Senate at 4:05 a.m. was 33-27 with 3 abstentions.
The lower house already passed the bill and President Cristina Fernández de Kirchner strongly supports it.
"The bill has passed. It is law. The executive power will be notified," the Senate president said as the vote was displayed on an electronic board in the chamber.
The debate lasted nearly 15 hours.
"The result sparked euphoria among the ( LGBT ) activists who, despite the polar wave that grips the city, held a vigil in the Plaza of the Two Congresses," said Buenos Aires' Clarín newspaper.
The Web site of Argentina's main political gay group, la Federación Argentina LGBT, was kicked off the Internet and replaced with a "Bandwidth Limit Exceeded" notice.
"Today's historic vote shows how far Catholic Argentina has come, from dictatorship to true democratic values, and how far the freedom-to-marry movement has come as twelve countries on four continents now embrace marriage equality," said Evan Wolfson, head of the U.S. group Freedom to Marry.
"Key to Argentina's human rights achievement was strong leadership from legislators and the president. It is time we see more of our own elected officials standing up for the Constitution and all families here in the United States," Wolfson said. "America should lead, not lag, when it comes to treating everyone equally under the law."
Same-sex marriage is legal in Argentina, Belgium, Canada, Iceland, the Netherlands, Norway, Portugal, South Africa, Spain, Sweden, Mexico City, Connecticut, Iowa, Massachusetts, New Hampshire, Vermont and Washington, D.C.