Duda scored 34.8 per cent against Komorowski's 32.2 per cent, with rock star and political novice Pawel Kukiz trailing at 20.3 per cent, according to an exit poll by Poland's TVP public television broadcaster.
"This result is a serious warning for the entire governing camp. We have to listen to the voters' voice," a sombre Komorowski yesterday told campaign staff in Warsaw in a reference to the fact that his political allies in the ruling centrist Civic Platform (PO) face parliamentary polls in the fall.
Duda, speaking to wild applause at his Warsaw campaign headquarters, said: "In order to live with dignity in a secure Poland, many areas must be fixed and the repairs must begin with a change in the office of president."
The 42-year-old lawyer is backed by the Law and Justice (PiS) conservative opposition party, which is gaining ground against the PO ahead of the parliamentary polls.
More From This Section
"Voters are saying you have to slow down and be more honest, creating a less liberal Poland, focused more on social welfare," political analyst Eryk Mistiewicz told AFP.
"His promises go well beyond the powers of the president," Radoslaw Markowski, a political scientist at the Polish Academy of Sciences said, warning that Duda's platform "would even ruin the (much larger) German budget!"
Komorowski, a 62-year-old historian, took office in 2010 after the death of his predecessor in a plane crash. His campaign was centred on national security concerns raised by Russia's meddling in neighbouring conflict-torn Ukraine.
Unlike Komorowski, Duda agrees with Poland's powerful Catholic Church in its opposition to in vitro fertilisation. Duda also won the support of the Solidarity trade union.
The PO's unkept promises on tax reforms for small and medium-sized businesses have undermined support for Komorowski.