TORONTO -- Jim Flaherty was remembered Wednesday with equal measures of laughter and tears as Canada's political elite gathered to set aside their partisan differences and pay their final respects to the former finance minister.

Mourners donned green scarves, a tribute to Flaherty's Irish heritage, inside the majestic St. James Anglican cathedral in downtown Toronto as they celebrated the diminutive, combative politician, who died of a heart attack last week at the age of 64.

Flaherty converted to Anglicanism when he married his wife, Ontario MPP Christine Elliott, 28 years ago.

"What a sad time this is in the life of our country," said Prime Minister Stephen Harper, who began the proceedings with an upbeat personal tribute to his longtime political confidante.

Harper not only poked fun at himself by comparing his own popularity to Flaherty's -- "I can't even get my friends to like me," the prime minister joked to gales of laughter from the congregation -- but he revealed how his finance minister told him four years ago he wanted to leave politics. Flaherty finally quit last month.

Flaherty said in 2010 he wanted to return to the private sector in order to put more money aside for his family, Harper recalled, but was first insistent on ensuring the Canadian economy was out of the woods following the 2008 economic downturn.

"And every year after that, without any prompting from me, the call would come and Jim would say: 'Prime Minister, I'm still worried about the global economy and we're not yet in balance. I want to do one more budget."'

Directly addressing Elliott and the couple's triplet sons, Harper said, "We have lost a partner in politics, but you have lost a partner in life."

Harper fought back tears twice during his remarks, which were otherwise a cheerful, light-hearted look back on the time he and Flaherty shared together in power on Parliament Hill.

"Occasionally, I imposed a final decision," Harper said of their periodic cabinet-table disputes.

"Occasionally I decided he was probably right. And occasionally, I decided he was wrong, but let him have his way because I just got so damn tired of arguing with him."

But as his eulogy drew to a close, Harper had to compose himself as he described the day he accepted Flaherty's resignation just a few short weeks ago.

"I told Jim that he had truly been over these eight years, in my judgment, the best finance minister in the world, if not indeed the best in our history," Harper said.

"I also wished him well in his next career ... and I told him not to be a stranger."

One of the most touching moments came when the prime minister directly addressed Flaherty's triplet sons, the 23-year-old John, Galen and Quinn.

"I lost my own father almost exactly 11 years ago, to the day," he said. "That period, I remember almost nothing of what I said or what was said to me, so powerful were the waves of emotion.

"But once that passed and perspective took hold, I came to appreciate my father's place in my life probably even more fully and deeply than if he were still here. And it is all good, and it will be all good for you."

Liberal Leader Justin Trudeau, NDP Leader Tom Mulcair and former prime ministers Brian Mulroney, Kim Campbell and John Turner were among those on hand for the funeral, as were various federal cabinet ministers, including John Baird, Peter MacKay, Jason Kenney and James Moore.

Harper and his wife, Laureen, arrived in advance of the cortege, followed by Gov. Gen. David Johnston and his wife. Harper exchanged pleasantries with Mulroney and shook hands with Ontario Premier Kathleen Wynne as they sat down.

At one point, Mulroney and an ailing Turner, famous political rivals, were seen to exchange smiles and nods.

A host of familiar faces from the Ontario legislature -- former premier Ernie Eves and Conservative Leader Tim Hudak among them -- were also present.

Flaherty's sister, Norah, told the story of how their mother once discovered him throwing pennies in the trash -- a foreshadowing, perhaps, of his decision in 2012 to do away with the costly one-cent piece.

"When Mum asked Jim why he was throwing out the pennies, he said, 'They're not worth anything,"' she said. "Somewhat prophetic."

Harper and his wife were particularly emotional during Norah Flaherty's remarks, frequently dabbing their eyes as she spoke of what a loving and loyal brother he was to his seven siblings.

A sombre but composed Elliott was effusive in her praise of her husband.

"He was the most intelligent man I ever met, and his clarity of thought was unparalleled," she said.

"He was a proud Canadian who loved our great country, and even when his life became more difficult in the last year or so, he persevered until he was certain he would leave things in order for his successor."

Added Quinn, in a poignant message to his father: "Put your feet up, lay your head back, close your eyes and relax. We will take it from here."

Flaherty's death, which came less than a month after his retirement as minister, sent shock waves through the national capital, where flags have been flying at half-mast and the Peace Tower has been bathed in green light.

Labour Minister Kellie Leitch, a Flaherty confidante who rushed to his condo in an attempt to revive her friend and had dinner with him on the eve of his death, delivered a reading at the funeral on Wednesday.

Mark Carney, the former Bank of Canada governor who now heads the Bank of England, was also on hand at the funeral, which took place under tight security just blocks from Toronto's famed financial district, a favourite Flaherty stomping ground.

Toronto Mayor Rob Ford, whose friendship with Flaherty caused the diminutive finance minister some uncomfortable moments in the media spotlight last year, was also in attendance.

Before the proceedings got underway, a choir assembled behind the altar and an organist filled the chamber with hymnal music as mourners awaited the arrival of the cortege carrying Flaherty's casket. The towering archways of the cathedral were bathed in green light.

Large white tents were erected on the lawn of the cathedral. Across the street, a phalanx of TV cameras documented the arrival of family, friends and dignitaries.

Onlookers began gathering several hours before the ceremony was scheduled to begin. One man had his patriotism on full display, wearing a white jacket adorned with a red maple leaf and clutching a Canadian flag.

The busy downtown Toronto streets surrounding the church were closed to all vehicular traffic, except for streetcars.

The ceremonial journey of the casket began in Whitby, Ont., and proceeded along Highway 401, down the Don Valley Parkway and through downtown Toronto before its scheduled arrival at the church just before 3 p.m. ET.

Hundreds of dignitaries and citizens had lined up to pay their respects Tuesday at Whitby's Abilities Centre, which caters to the disabled and able-bodied alike. Harper arrived late in the day for a private viewing.

Flaherty's state funeral is the first such honour since 2011, when former NDP leader Jack Layton was laid to rest.

State funerals are customarily only given to current or former prime ministers, governors general, sitting cabinet ministers or members of the Royal Family.