(CNN) -- Two national police officers were wounded Sunday when a gunman shot at officers outside the Italian prime minister's office, authorities said.
The gunman, described as a 49-year-old man, fired six shots at police before being taken into custody, said a national police officer who was not authorized to speak to the media.
The officers didn't suffer life-threatening wounds, and the shooter was also hospitalized -- though not wounded, the source said.
Francesco Puglisi, a journalist for Il Tempo newspaper, heard the shots from his office, then saw police tackle the man.
He ran to the scene and said the face-down suspect appeared calm and was complying with police.
The gunman wanted to commit suicide after the attack but ran out of bullets, Italian Interior Minister Angelino Alfano said in a televised statement.
The shooting took place in front of the prime minister's office, but Enrico Letta was being sworn in as prime minister at the time at the president's palace a short distance away, state-run news agency ANSA said.
The agency also reported that prosecutor Pierfilippo Laviani said the shooter had confessed and was hoping to shoot politicians but found none so he struck out at police.
Security at key government buildings was strengthened after the attack, though officials said they thought it was an isolated incident.
The shooter, who is unemployed, lives in the southern region of Calabria, officials said.
On Saturday, Letta, a center-left politician, accepted a mandate to form a government from President Giorgio Napolitano.
The 46-year-old former deputy prime minister and his ministers were sworn in Sunday, and parliament is expected to confirm his government through a vote of confidence Monday.
Letta's acceptance of the leadership role is expected to limit the uncertainty that has gripped the nation since February when elections left none of the candidates with enough support to form a government.
U.S. Secretary of State John Kerry called Letta a trusted friend of Washington.
"We wish him the best as he promotes reform at home and ensures continued Italian leadership abroad, and we look forward to continuing our close cooperation with Italy on many pressing issues all over the world," Kerry said.