Gentiloni, a member of Prime Minister Matteo Renzi's centre-left Democratic Party (PD), replaces Federica Mogherini, who was set to take on her new role as foreign policy chief in Brussels on Saturday.
"I thank President Giorgio Napolitano and Prime Minister Renzi for their trust. I know it is a great responsibility," Gentiloni told journalists after his swearing in ceremony.
His appointment was met with a stream of messages from well wishers within the government and centre-left.
"Congratulations to Paolo Gentiloni, new foreign minister," Deputy Foreign Minister Lapo Pistelli, who had been one of the frontrunners for the job, said on Twitter.
MP Lia Quartapelle, a 32-year-old widely tipped in the run-up to Mogherini's resignation as having been Renzi's favourite for the job, wished Gentiloni luck, saying he had "the right political profile to guide our country's foreign policy."
The official confirmation of his appointment came after a swearing-in ceremony in front of President Napolitano in the presidential palace in Rome.
Gentiloni is known to be a close ally of leftist Renzi and reactions to his appointment were lukewarm from the centre-right, with former premier Silvio Berlusconi's political advisor Giovanni Toti saying the new minister would have "a lot to do".
The anti-immigration Northern League party was also underwhelmed, describing the nomination as "a second-rate compromise" and questioning whether Gentiloni had the necessary experience and clout for the role.
"Is this a joke or what? We don't know whether to laugh or cry," the league's leader Matteo Salvini said.
Gentiloni, who will be 60 next month, is former journalist who studied political science. He held the post of communications minister under Prime Minister Romano Prodi between 2006 and 2008.
He had held aspirations to become mayor of Rome but was defeated in the left's primaries in 2013, and has been a member of the lower house of parliament's foreign and European affairs commission since last year.