With 36% of the ballots counted, Nikola Gruevski's VMRO-DPMNE party had won 33% of the vote, while Buckovski's ruling Social Democrats had 24%, according to preliminary results released by the State Electoral Commission.

"I called Nikola Gruevski to congratulate him with his election victory," Buckovski told his supporters in a televised speech just after midnight on Thursday.

Gruevski, a former finance minister, was quick to claim victory, with pledges to get to work on repairing the economy.

Violence

The tense electoral campaign was marred by violence - including gun battles and a grenade attack - between supporters of rival ethnic Albanian parties that left at least three people wounded.

However Wednesday's voting passed off peacefully, and the prime minister cheered it as a "victory for Macedonia" despite his apparent loss.

The process was likely to please the European Union and Nato, which had appealed for a politically mature election.

"We have said that we will be satisfied if we have a free and peaceful election, if we pass this test. We had an exceptionally good election and this is victory for Macedonia," Buckovski said.

Macedonia split from Yugoslavia peacefully in 1991 but ethnic conflict caught up with the republic of two million in 2001 when a six-month Albanian insurgency drove it close to civil war.