By Aleksandar Vasovic

BELGRADE (Reuters) - Serbia should be prepared to further tighten border security, President Tomislav Nikolic said on Monday, in a sign regional leaders have been emboldened by Hungary's defiant line on migration.

Serbia should act even if it risks incurring the wrath of the European Union, which it is seeking to join, Nikolic said.

Along with other southeast European countries, Serbia has intensified border patrols against hundreds of thousands of refugees and migrants fleeing war and poverty in the Middle East and North Africa, cooperating with European efforts to channel flows through the Balkans.

But with Hungary's border all but fully sealed, growing numbers of refugees are trapped in Serbia with no way of continuing toward the wealthier countries of northern Europe that most hope to reach.

"If Serbia becomes a funnel from which water cannot drain because others further along have shut their own borders, Serbia must shut down its own (borders) regardless of its convictions," Nikolic said, according to Tanjug agency.

Since July, the number of migrants stranded in Serbia has risen by 3,000, and tensions are rising in refugee camps.

Hungary's Prime Minister Viktor Orban said he would amend the constitution to ensure the European Union cannot settle migrants in Hungary after a referendum on Sunday.

While almost all Hungarians who voted on Sunday rejected the EU's migrant quotas, turnout was too low to make the poll valid.

"If Hungary did not anger the EU, Serbia will surely not," Nikolic said.

In August, Orban announced plans to build a second fence along Hungary's border with Serbia to keep migrants out.

Though his powers are mainly ceremonial, Nikolic is a close ally of Prime Minister Aleksandar Vucic, both of whom are former radical nationalists who went on to found the ruling center-right Serbian Progressive Party.

Last year, hundreds of thousands passed through Serbia heading to the EU's passport-free Schengen zone. Numbers are lower this year but more than 100,000 migrants have reached the Balkans so far in 2016.

Serbia is an EU membership candidate, but before it joins the bloc it must reform its judiciary, rule of law and economy.

(Reporting by Aleksandar Vasovic; Editing by Thomas Escritt and Janet Lawrence)