By Tsvetelia Tsolova and Angel Krasimirov

SOFIA (Reuters) - Bulgaria's center-right GERB party narrowly won a parliamentary election on Sunday, giving it a chance to form another government after leader Boiko Borisov resigned as prime minister in November, triggering the snap poll.

The GERB party won 33 percent of the vote, the Balkan country's third in just 4 years, with the leftist Socialists trailing on 27.2 percent, partial official results with 26 percent of the ballots counted showed.

"The result of the vote shows that GERB is obliged to form a government," said Borisov.

The election had been seen as a test of Bulgaria's loyalties to the European Union, which it joined in 2007, and to Russia, with which it has historic political and cultural links.

The Socialists, who had pledged to improve ties with Russia even if it meant upsetting EU partners, doubled their share of the vote compared to the last election in 2014 but failed to overtake the strongly pro-EU GERB.

If Borisov, 57, succeeds in forming a new coalition, it is likely to maintain the tight fiscal policies that underpin the lev currency's peg to the euro.

GERB is expected to court the United Patriots nationalist alliance, which came third with 9.6 percent of the vote, followed by ethnic Turkish party MRF with 7 percent, according to partial official results. The Populist Will party will also enter the next parliament.

Political analysts are skeptical the results can lead to a government able to uproot widespread corruption in the EU's poorest member state.

"I am not optimistic that these results will lead to the formation of a stable majority that can pursue strong policies," said Ognyan Minchev, a political analyst with the Sofia-based Institute for Regional and International Studies.

"It is likely to be fragile and unstable," he said.

ANTI-MIGRANT SENTIMENT

The United Patriots has built its popularity on anger about the flow of migrants from the Middle East, Africa and Asia trying to reach Western Europe via the Balkans.

Story continues

On Friday, supporters of the alliance blocked Bulgaria's border crossings with Turkey in an effort to stop buses bringing Bulgarian ethnic Turks to vote in Sunday's election.

Ahead of the election, Borisov signaled he hoped to include the Reformist Bloc in a GERB-led coalition government, but exit polls suggested the right-wing group had failed to secure enough votes to make it into parliament. That will likely complicate coalition talks.

Socialist leader Kornelia Ninova, 48, conceded defeat in the election but said she would look at options for forming a government in case GERB cannot do so.

The Socialists had pledged during campaigning to raise wages and pensions as well as oppose continuing EU sanctions against former Soviet-era overlord Russia.

That would complicate relations with Bulgaria's EU peers -- already grappling with Britain's move to leave and the rise of anti-establishment parties across the bloc -- as it gets ready to take over the EU's six-month rotating presidency in January.

Borisov resigned after a GERB candidate lost a presidential election in November to Rumen Radev, a Russia-friendly ally of the Socialists, and Bulgaria is currently being run by a caretaker administration.

(Reporting by Tsvetelia Tsolova and Angel Krasimirov; Editing by Catherine Evans and Andrew Hay)