Updated

Canada's finance minister says Canada is not in recession now and wasn't in recession in the first half of the year despite data showing otherwise.

Joe Oliver said in an interview with The Associated Press the downturn was largely confined to the energy sector. Canada fell into a recession in the first six months of the year, dragged down by falling energy prices and economic troubles in China.

The Canadian economy retreated at an annual pace of 0.5 percent from April through June after sliding 0.8 percent the first three months of the year. Two consecutive negative quarters are the technical definition of a recession.

"We don't believe that the economy was in fact in a recession," said Oliver, whose Conservative party is seeking re-election on Oct. 19.

"We're really talking about a contraction in the energy and resource sector of the economy which is less than 20 percent of the economy. Granted there is a spillover but the other 80 percent was growing."

Oliver noted the economy grew at 0.5 percent pace in June, the first monthly gain in six months. He said whether Canada was in recession is a matter of continuing debate.

"But I can tell you this, we don't believe we're in a recession at all now," Oliver said. "The trade numbers are robust. Consumer confidence is good and we returned a budget surplus."

Canada is the world's 11th-biggest economy and the United States' biggest trading partner. The Canadian economy suffered far less damage from the financial crisis and Great Recession than its southern neighbor. But news this month of a recession spelled trouble for Prime Minister Stephen Harper. Polls show the election is a three-way toss-up. Harper is campaigning for a rare fourth term on a record of economic growth.

Beata Caranci, Chief Economist for TD Bank, said while the Canadian economy did technically contract in the first half of 2015 but the job and housing markets held up well and she said forward indicators show Canada is looking at a "pretty nice rebound. "I feel confident that we're on a pretty good expansion path right now," Caranci said.

Craig Wright, Chief Economist at the Royal Bank of Canada, called the first half of the year a "soft patch" rather than a recession and said conditions have improved. "You are looking at a 0.1 percent drop on a two trillion economy. It's kind of a rounding error and it may be revised away," Wright said.

Oliver, however, said they are mindful of the external risks to the Canadian economy.

According to a government memo prepared for Oliver on the global economy the trade impact on Canada of a more prolonged slowdown in China would be significant, noting China is Canada's second largest export partner, with exports with exports equivalent to roughly one percent of Canadian GDP.

But Oliver said the global economy is not in crisis like it was in 2008 and said Canada doesn't need the stimulus spending the opposition Liberals in Canada are advocating. The Liberals vow to invest in infrastructure to get the economy going and say they'll run deficits of $10 billion ($7.5 billion) in each of the next three years if elected.

Canada posted a budget surplus after six straight years of deficits. The government earlier this month announced a $1.9 billion Canadian (US$1.4 billion) surplus for last year.

Oliver, who met with finance ministers and central bank governors from the Group of 20 leading economies in Turkey earlier this month, said other countries could learn from Canada.

"The contrast is very clear. When I was sitting around the table in Ankara I couldn't help but think that if some of these other countries that we are talking about had followed our path of low taxes and balanced budgets they wouldn't be in the difficulty they are today," Oliver said.

"We're in a period of growth and we're anticipating our surpluses to get larger in the years ahead."

Oliver, previously the country's natural resource minister and a strong proponent of the Keystone XL pipeline, did the interview on Tuesday just before U.S. Presidential contender Hillary Clinton said she opposes the controversial pipeline. Canadian Prime Minister Stephen Harper said as recently as last month that he was confident that whoever became the next president would approve Keystone. News that Clinton opposes it is a blow to Canada, which needs infrastructure to get its oil to market. Canada has the world's third largest oil reserves.

Wright, the economist, however, said the pipeline isn't as critical to the Canadian economy as it once was as oil companies have increasingly used trains to get oil to market.