The bill had overwhelming support among council members and was expected to pass, though opponents have vowed to try to get Congress or voters to overturn it.
David Catania, who introduced the bill and is one of two openly gay council members, called the bill a "matter of social justice" before the vote.
Two members voted "I do" when their names came up, and when the vote finished a packed chamber erupted into cheers and clapping. The "no" votes included former mayor Marion Barry, now a council member.
If Congress does not reject the bill, the district will join Connecticut, Iowa, Massachusetts and Vermont in issuing marriage licenses to same-sex couples. They will be able to wed in New Hampshire starting in January.
Gay marriage supporters have had less success elsewhere recently. Maine voters overturned the state's same-sex marriage law last month. Earlier this month, the New York state Senate rejected a bill that would have allowed gay couples to marry. And New Jersey's legislature, which had been working on a same-sex marriage bill, postponed a recent vote when the measure appeared headed for defeat.
Tuesday's vote in the district came after several months of discussion, including two marathon council hearings at which some 250 witnesses testified.
Opponents included the Archdiocese of Washington, which said it might have to stop providing adoptions and other services because the law would force it to extend benefits to same-sex couples. But most who testified in this overwhelmingly Democratic city were supporters.
Some, teary-eyed, asked the council to let friends, relatives or themselves marry. One man proposed to his partner during his testimony.
The law will likely take effect around St. Patrick's Day in this city of 600,000, which is about 1/17th the size of Rhode Island. Congress has 30 working days to reject it, but that has happened just three times in the past 25 years and appears unlikely in this case.
Still, opponents plan to try. Members of a group called Stand4Marriage, led by local pastor Bishop Harry Jackson, have met with members of Congress to urge them to oppose the bill.
Attorney Cleta Mitchell said that after Fenty signs the bill and it goes to Congress, the group will ask a district elections board to put a referendum on the ballot asking voters to overturn it. She said in a statement before the vote that the law is a "decision for the people, not a dozen people at city hall."
The group Mitchell represents made a similar request this summer, when the city passed a law recognizing gay marriages legally performed in other states. The board declined to put the issue on the ballot, saying that would violate a city human rights law.
The group also has a lawsuit pending from earlier this year, when it tried to get an initiative on the ballot asking voters to define marriage as between a man and a woman. The elections board again cited the human rights law in saying no. A hearing in that case is scheduled for February.