The Roman Catholic Church and conservative opposition have fiercely opposed the move, which opinion polls suggest has the public's support.
If the bill is approved by parliament, it will make Spain the third EU country to authorise gay marriages.
The government, which estimates around 10% of Spaniards are gay, says it expects homosexuals to be able to marry as early as next year.
The issue of adoption further fuelled the controversy, stiffening opposition from the church.
Institution
After the vote, the Spanish Bishops' Conference issued a statement saying the cabinet's decision was "wrong and unjust".
"A married couple, producing and educating their children, contributes in an irreplaceable way to the growth and stability of society," the bishops said, adding that a homosexual couple "could never have such characteristics".
They said gay people's rights as citizens should not be discriminated against, but insisted social institutions had to be protected.
"Marriage is essentially a heterosexual institution," they said.
But Cabinet spokeswoman Maria Teresa Fernandez de la Vega said thousands of children lived with homosexual parents and numerous studies had shown that they were no different to children brought up in heterosexual homes.
"There is no proof that homosexual parents educate their children any worse. In adoption, the well-being of the children comes first, independent of the sexual orientation of the parents," she said.
The Christian Association of Gays and Lesbians welcomed the cabinet's decision.
Respect
Gwenael Le Moing, of the association, said that the law would help the normalisation of homosexuality in society - "although there was still a lot of work to do".
"It also leaves the church more and more isolated in its discriminatory position."
The adoption part of the bill will allow gay couples to adopt only Spanish children, to avoid any legal wrangles with other countries. Under the bill, married gay couples will also be entitled to draw a pension after a partner's death and to divorce.
Church leaders had earlier compared the plans to releasing a virus into society and called on politicians to reject them.
Socialist Prime Minister Jose Luis Rodriguez Zapatero took office in April, intending to remove what he called the Church's undeniable advantages and create a secular state with streamlined divorce and relaxations in abortion law.
Earlier this week he said: "I deeply respect the opinions of the Catholic Church even if they are very critical of the government. I ask them to show the same respect."
The Church's influence on Spaniards has declined precipitously since the death in 1975 of the dictator General Francisco Franco. His regime was closely linked to the Church.
Opinion polls suggest that nearly half of Spaniards now almost never go to mass.
July 2004 August 2004 September 2004 October 2004 November 2004 December 2004 January 2005 February 2005 March 2005 April 2005