(Adds quotes from debate, analysis)
By David Ljunggren and Randall Palmer
OTTAWA, Sept 17 (Reuters) - Canadian Prime Minister Stephen Harper, taking the offensive after an election campaign marred by setbacks and missteps, told a televised debate on Thursday that his rivals' plans for increased taxes and deficits would badly damage the economy.
With polls showing a tight three-way race ahead of the Oct. 19 vote, Harper needs to break away from his two center-left opponents if his Conservatives are to extend their near 10-year term in office.
In contrast to debates in past elections, where Harper was the main target, his rivals spent as much time attacking each other as they did taking jabs at the prime minister.
The result was an often-confusing cacophony, which pollster Nik Nanos said likely reinforced rather than swayed opinions.
Harper has long portrayed himself as the only leader able to handle a sluggish economy amid global weakness. This week he trumpeted the federal budget's return to surplus a year earlier than predicted.
"The other parties are trying to tell us they will deal with the challenges of our economy, of our labor market, of international markets, by raising taxes and running deficits to finance vastly increased amounts of spending," he said.
"That is not the way to protect our economy in this environment," he said in testy exchanges with New Democratic Party leader Thomas Mulcair, 60, and Liberal Justin Trudeau, 43.
Harper says Canada should stick to Conservative policies designed to keep taxes low and attract investment. He brushes off calls for more spending.
The Liberals are proposing three years of budget deficits to help finance an infrastructure program to boost the economy.
"You are disconnected from people's reality," Trudeau told Harper. "Canadians are worried about their jobs, and that's what this election is about."
While the two opposition party leaders delivered a number of such jabs at the prime minister, they also tore into each other to try to sway anybody-but-Harper voters.
"The switch voters are between those two parties, and they are going to go at each other," said Ipsos Public Affairs pollster John Wright.
Mulcair pointed out that Trudeau had said in July that he would balance budgets but he was now promising deficits.
"I think, Justin, it's only fair to say that when your advisers tell you one thing and then another and they're totally contradictory, pick one. You can't just say them both," he said.
The New Democrats, who have never held power federally, pledge higher corporate taxes and balanced budgets..
Google Canada said searches during the debate for Trudeau narrowly edged Harper, and outpaced Mulcair by 80 percent.
The debate, the second of the campaign, was sponsored by the Globe and Mail newspaper. It took place in Harper's adopted hometown of Calgary in the energy-producing province of Alberta, hard hit by slumping crude prices.
Mulcair accused Harper of relying far too much on oil exports to buoy government finances: "Mr. Harper put all his eggs in one basket and then he dropped the basket." (Editing by Bernadette Baum and Ken Wills)