European Commission president Ursula von der Leyen congratulated Mr Duda on his win, tweeting that she looks "forward to working with him on the many challenges Europe and Poland have to face together."
Experts said the result means the governing PiS party, which has been criticised at home and abroad for reforms of the judiciary seen as eroding democratic freedoms, will face a more confident opposition.
"President Duda has won the election but the real success is for Rafal Trzaskowski and the opposition which has gained ground," said Kazimierz Kik, a political expert from Kielce University.
Anna Materska-Sosnowska, a Warsaw University political scientist, warned there was a "realistic" risk that Poland could begin to resemble Hungary, which has been accused of drifting towards authoritarianism under nationalist Prime Minister Viktor Orban.
'Poland divided in two'
After congratulating Mr Duda on Monday, Mr Trzaskowski called on the president to "free himself from his political party", adding: "I hope the president will display more independence in his second term."
Mr Trzaskowski vowed to work hard "to sew Poland back together", a sentiment echoed by Mr Duda, who asked supporters to "help me glue our Poland together" by respecting those with different views.
The government must now deal with fallout of the coronavirus pandemic, which is pushing Poland into a recession - the country's first since communism fell three decades ago.
"Poland is split down the middle," remarked Witold Orlowski, a professor at Warsaw University of Technology Business School who forecast "a very difficult period" ahead.
"On the one hand, even this slim victory is a PiS success and will allow it to continue to govern, at least technically," Prof Orlowski said.
"On the other hand the social and economic situation will deteriorate and a large part of the electorate will blame the PiS."
Internationally, experts said Mr Duda's close ties with Mr Trump could also spell trouble ahead if the US president fails to win re-election in November.
Mr Duda's support was particularly strong among older voters in rural areas and small towns and in the east of the country, while Mr Trzaskowski did well with a younger electorate in larger cities and western regions on the border with Germany.
"The result of these elections is a Poland divided in two with a not-so-rosy future, as it will be difficult to ease the division and to restore the relationship between the two sides," Mr Kik told AFP.
White-red vs rainbow
The election was to take place in May but was delayed because of the virus.
Four days before the first round, Mr Duda became the first foreign leader to visit the White House since the pandemic struck, and was praised by Mr Trump for doing an "excellent job".
Justice Minister Zbigniew Ziobro characterised the second round vote as "a clash of two visions of Poland, the white-red and rainbow-coloured," referring to the colours of Poland's national flag and the symbol widely used by the LGBTQI+ community.
Mr Duda has railed against "LGBT ideology", likening it to a new form of communist brainwashing, and has vowed to change the constitution to rule out adoptions by same-sex couples.