Layton passed away at his home in Toronto early on Monday surrounded by his wife and children, his family said in a statement.
His New Democratic Party (NDP) surged to become the official opposition for the first time in May’s federal elections.
He stepped down only last month as party leader to fight his illness.
In a letter released by the NDP after his death was announced, Mr Layton said he remained optimistic about Canada’s future and its political system.
“Unfortunately my treatment has not worked out as I hoped,” he said. “So I am giving this letter to my partner Olivia to share with you in the circumstance in which I cannot continue.”
Layton urged readers to “to cherish every moment with those you love at every stage of your journey, as I have done this summer”.
He described Canada as “a great country, one of the hopes of the world”.
“We can be a better one,” he added, “a country of greater equality, justice, and opportunity.”
Layton called on members of his party to remain committed to their “proud history of social justice”, universal healthcare and public pensions.
To young Canadians, he spoke of his “belief in your power to change this country and this world”.
Prime Minister Stephen Harper saluted his late adversary’s “contribution to public life, a contribution that will be sorely missed”.
Canadians paid tribute at Layton’s constituency office in Toronto At Parliament Hill in Ottawa, the Canadian capital, the flag was lowered to half-mast on Monday.