By Krisztina Than and Marton Dunai
BUDAPEST (Reuters) - Hungary's two main opposition parties joined forces ahead of an election due in 2014, an alliance that could pose a real challenge to Prime Minister Viktor Orban's ruling party which has so far benefited from deep divisions on the left.
The Socialist Party and former Prime Minister Gordon Bajnai's Egyutt 2014 agreed on Thursday on a mechanism to decide who will be their joint candidate for prime minister - an issue that caused months of wrangling - and pledged to split the field for parliamentary seats and support each other's candidates.
Orban's conservative party, Fidesz, has a firm lead in opinion polls ahead of the vote, due in April or May. But about half of Hungarian voters are undecided and the economy is barely growing after a recession last year.
Voters in Hungary's election system cast two votes: one for individual candidates and one for the preferred party.
According to the pact, although the two leftist parties will essentially field joint candidates for constituencies in parliament, they will still run as separate parties.
If Orban is defeated, the party which wins more votes in the party vote will nominate the prime minister, and the other party will accept that result, without conditions.
"The alliance that will replace Viktor Orban has been born today," Socialist leader Attila Mesterhazy told Reuters. "Everyone is satisfied with this, and now all voters can choose the candidate closest to their liking."
"The cooperation is of one hundred percent. The differences have been worked out in an hour and a half between Mr. Bajnai and myself, and our confidence in each other is complete."
The Socialists will field candidates in 75 of Hungary's 106 constituencies and Egyutt 2014 in the remaining 31, according to the agreement.
"This day is the end of a difficult start for the opposition and the beginning of the end for the Orban regime," Egyutt (Together) 2014 said in a statement.
Mesterhazy's Socialist Party evolved from the communists who ruled Hungary from 1956 to 1989 and has stronger support in opinion polls than Egyutt 2014.
Bajnai led a Socialist government from 2009 to 2010 that introduced painful spending cuts to put the economy back on a sustainable path.
The deal comes less than a week after talks between the two parties stalled over the premiership issue.
"This solution allows the leftist parties to address a wider electoral base than in a full-on alliance," said Peter Kreko, analyst at think tank Political Capital.
"Those who are weary of Bajnai can vote for the Socialists (in the party vote) and vice versa.
"The leftists can profit from this setup if they rest their differences on the national level and both compete against Orban. That can improve them. If their conflicts remain, Fidesz will walk home with the easy win," he said.
In the last poll by pollster Ipsos in August, public support for Fidesz was at 26 percent, while the Socialists (MSZP) scored 15 percent and Egyutt had 4 percent. Some 43 percent of those polled said they were still undecided.
(Reporting by Krisztina Than/Marton Dunai; Editing by Sonya Hepinstall)