The attacker, dressed in camouflage clothing, eluded the attention of Klaus' security detail as he pushed his way through a crowd at a ceremony to open a bridge. Security police did not react when the assailant, identified only as a 26-year-old man, pulled a pistol used in "airsoft" gaming, the BBC reported.
Czech channel TV Prima showed footage of the president recoiling slightly but carrying on the visit.
Klaus was taken to a hospital where he was reported to have only slight bruising.
Interviewed briefly by Czech media, the man said he attacked Klaus because the government was unconcerned about the plight of ordinary people.
The post of president is largely ceremonial. Klaus served as prime minister in the 1990s.