Polish President Andrzej Duda is a loyal ally of the ruling nationalist Law and Justice party (PiS) and his re-election means the party's socially conservative programme can continue unhindered for another three years.
It was a narrow victory, but the high turnout means President Duda won a clear mandate, the BBC's Adam Easton reports from Warsaw.
PiS policies, strongly influenced by Catholic traditions, are very controversial both inside Poland and in the EU.
President Duda supports the government's legislative changes to take greater control over independent institutions, most prominently the public media and judiciary.
But in 2017 the European Commission took the unusual step of launching a rule-of-law case against Poland, accusing PiS of undermining basic EU values - a procedure that could lead to Poland's EU voting rights being suspended.
Poland is the largest net recipient of EU budget funds, and some in the EU favour tying those payments to Polish compliance with EU principles, as enshrined in the treaties.
Under the current government the justice minister is also prosecutor general, giving him extraordinary power over the conduct of prosecutions.
The president has the power of veto over legislation - and victory for Mr Duda's rival, liberal centrist Rafal Trzaskowski, would have jeopardised PiS ambitions.
'Our inviolable tradition'
Mr Duda, 48, said he would continue strengthening the Polish state, "built on our inviolable tradition, which is sacred to all of us and in which we have been brought up for generations".
He once described the EU as "an imaginary community from which we don't gain much".
He is a lawyer by training, and won a surprising victory in 2015, after PiS had lost a string of elections under all-powerful party leader and candidate, Jaroslaw Kaczynski.
Mr Duda was close to Mr Kaczynski's twin brother and former president Lech, who died in 2010 when the presidential jet crashed in Smolensk, Russia.
After PiS first came to power in 2005, Mr Duda served as an aide to Lech Kaczynski. Later he was elected to the Polish parliament and the European Parliament.
He is a socially conservative Roman Catholic, who supports the government's popular and generous welfare scheme. It is symbolised by the 500+ programme, under which families receive 500 zloty (£100; €110; $125) per month for each child until the age of 18.
Many Polish families have been lifted out of poverty as a result of the government's policies, and, for the first time since the end of communism in 1989, feel there is a party that cares about their needs.
This is especially true in villages and small towns, where PiS has its bedrock of support.
On the other hand, he has vowed to protect Polish families from what he calls an imported "LGBT ideology" that he says is aggressively trying to sexualise Polish children.
He came under fire during the election, including for a speech in which he said LGBT rights were an "ideology" more destructive than communism.
In practice, sex education classes in Polish state schools do not exist.
Instead students have more wide-ranging "family life education" classes, which may include sex education, often led by priests or nuns.
Mr Duda favours making Poland's anti-abortion law even tougher. It is already among the most restrictive in Europe.
Power over media
Poland's public broadcaster, Polish TV, is funded by the taxpayer and is bound by its charter to present balanced coverage of political events.
Instead, in the run-up to the vote, its main evening news bulletin praised the government and Mr Duda daily and attacked Mr Trzaskowski, accusing him of being in cahoots with Jewish and LGBT interest groups.
Our correspondent says PiS may want to use Mr Duda's victory to pursue greater political control of local government and the private media. But passing legislation to limit foreign ownership of critical private media is difficult under EU rules.
Mr Duda, born in 1972, grew up in a family of professors in the southern city of Krakow.
His wife Agata is a German language teacher and they have an adult daughter, AFP news agency reports.