Jack Layton, the leader of Canada's official opposition, has died of cancer aged 61. Earlier this year, in May, Layton led his left-of-centre New Democratic party (NDP) to a historic victory in the federal election. The NDP won a record number of seats (103, up from a previous 37), emerging as the second party to Stephen Harper's triumphant Conservatives, and booting Michael Ignatieff's Liberals into third place for the first time since Canadian confederation in 1867. Just as remarkably, Layton became the first anglophone to win the province of Quebec against French-speaking opposition.

Layton was at the pinnacle of his career; no federal NDP leader had ever been opposition leader in the party's 50-year history. But he looked gaunt and sounded weak in July, when he announced that he was coping with cancer for a second time. He was characteristically optimistic about winning his fight and being back in the House of Commons in September.

Layton was born into a political family in Montreal and was raised in the small town of Hudson, Quebec. His father, Robert Layton, was a Conservative cabinet minister. Jack's paternal grandfather, Gilbert Layton, was also a politician; Jack's great-grandfather, Philip Layton, founded the Montreal Association for the Blind.

Layton attended Hudson high school and studied political science at McGill University in Montreal and at York University in Toronto. As a community organiser, he was passionate about environmental policies, poverty, homelessness and transport.

He worked as a teacher in the 1970s and served as a city councillor in Toronto and as deputy mayor of Toronto. In 1991 he made an unsuccessful bid to become mayor. He was elected leader of the NDP in 2003, and was elected to the Commons for the first time in 2004. In the 2006 federal election, the NDP placed fourth, with 29 seats. Two years later, they gained eight more seats in the election.

As NDP leader, Layton worked to secure benefits for the unemployed and more funding for social services. He also helped to shape the federal government's historic apology for the residential school system that separated aboriginal students from their families and sent them to church-run institutions where many were beaten and sexually abused.

Layton was shrewd and calculating, but also friendly and outgoing. His easy smile and an optimistic view of life led to his nickname, "Smiling Jack". He liked to ride his bike to work and took pride in his moustache. He had a real ability to connect with Canadians; poll after poll showed that he was the political leader they would most like to have a beer with. The former Canadian prime minister Jean Chrétien said that Layton was a good example of how politics can be a "noble profession". The NDP's Paul Dewar added that Layton's heart was "as big as a prairie sky", and that Layton had offered hope at a time when many people were turned off by cynicism in politics.

In his final press conference, Layton said he hoped to return to the Commons to build "the country of our hopes, of our dreams, of our optimism, our determination, our values and our love".

In 1988, he married Olivia Chow, a fellow city councillor in Toronto who was elected as an NDP member of parliament in 2006. He is survived by Olivia and by his children, Sarah and Mike, from his marriage to Sally Halford.

• John Gilbert Layton, politician, born 18 July 1950; died 22 August 2011