Macedonian Prime Minister Vlado Buckovski has conceded victory to the main nationalist opposition party in the general election.
Mr Gruevski: "Celebrate for a while and then work is waiting"
His Social Democrat-led coalition is trailing the VMRO-DPMNE party by nearly 10%, official preliminary results show.
Voting on Wednesday passed off without major incidents, despite some violence during the campaign.
The poll is being seen as a key test as to how quickly the Former Yugoslav Republic of Macedonia can join the EU.
"The opposition got the most votes and support of the citizens," Mr Buckovski said, adding that he had telephoned leader Nikola Gruevski to congratulate him.
"But Macedonia is the main winner as the citizens showed that they could vote in free and fair elections," he added.
"We want to tell the citizens that we'll be in the parliament to continue to work for Macedonia to be part of the EU integration."
Mr Buckovski's speech - coming an hour after VMRO-DPMNE declared itself the winner - answered the EU's call for a clear and prompt result.
The VMRO-DPMNE party secured 32.5% of the vote with Mr Buckovski's Social Democratic Union (SDSM) taking 23.2%, according to the official preliminary results announced by the electoral commission.
International observers said the election largely met international standards for democratic elections, but added that the campaign was marred by violence and intimidation, the watchdog body the Organization for Security and Cooperation in Europe (OSCE) said.
At a victory rally in the capital Skopje, Mr Gruevski, the former finance minister, said: "The citizens of Macedonia showed their maturity and made the right decision."
Mr Buckovski had sought a second term as prime minister
But he warned his supporters that after the celebrations, "work is waiting for us".
"Macedonia lost a lot of time in the last 15 years of transition. We have to form a government quickly and to focus on what we have promised our citizens."
Before Mr Gruevski can implement his policies he will almost certainly have to form a coalition with one of the main ethnic Albanian parties, the BBC's Nick Hawton in Skopje reports.
This could involve days if not weeks of negotiations, our correspondent says.
Some 1.7 million people were eligible to vote in what was Macedonia's fourth general election since gaining independence in 1991.
Extra police had been deployed following violence, mainly within the ethnic Albanian community, during the election campaign.
But while voting appeared to pass off relatively peacefully, the electoral commission did report some irregularities throughout the day.
Ballot-stuffing was reported at a couple of polling stations near the town of Tetovo, and there was an attempt to start a fire at one polling station in Skopje, which was quickly brought under control.
The EU had warned that future membership of the union could be severely delayed if there was serious trouble on polling day.
Macedonia was granted EU candidate status in December 2005.