Chretien said the new law would be drafted within weeks and submitted to the Supreme Court of Canada for review, then put to a Parliament vote. His Liberal Party has a commanding majority in the legislature, though the issue has caused division in the Liberal caucus.
The announcement means the government decided against appealing recent court rulings that declared the nation's definition of marriage as unconstitutional because it specified the union of a man and woman.
An Ontario appeals court last week declared that wording invalid, changing it to a union between two people.
"There is an evolution of society," Chretien said in making the announcement after a Cabinet meeting. He said the law would allow religions the right to decide what marriages should be sanctified.
An Anglican diocese in Vancouver has approved a blessing for same-sex unions, which it says is separate from marriage. The blessing ceremony, performed once so far, caused a split in the diocese with some churches dissociating themselves.
Opinion polls indicate a slight majority of Canadians favor legalizing same-sex marriages. After the Ontario appeals court ruling and similar previous ones by courts in British Columbia and Quebec, the government was under pressure to change the law or file appeals that would have left the issue unsettled.
Justice Minister Martin Cauchon said Tuesday it was time for change.
"We have decided not to appeal those rulings ... and proceeded with draft legislation that will be ready shortly ," he said. The new law would redefine marriage as called for by the courts while protecting religious freedoms, according to Cauchon.
"We're talking about essential freedoms here," he said.
Svend Robinson, a Parliament member for the leftist New Democratic Party who has pushed for same-sex marriages in Canada, praised Chretien's government for showing leadership. He rejected opposition by conservative political groups, who argue that changing the definition of marriage uproots a fundamental tenet of Canadian society.
Dozens of homosexual couples have obtained marriage licenses in the week since the court ruling, with at least one wedding taking place.
In the United States, homosexual marriage lacks full legal recognition in all 50 states. Vermont recognizes civil unions that give homosexual couples the full benefits and responsibilities of marriage but are separate from legal marriage.
By Colin McClelland