A young man managed to get within a metre of Czech President Vaclav Klaus to shoot him in the arm with a plastic gun firing pellets.
The president was unharmed but was reported to have told bodyguards that they had "not managed this well".
The attack took place during a ceremony to open a bridge in Chrastava, a village 100 km (60 miles) north of Prague.
The gun used by the attacker is usually used in a game called airsoft, similar to paintball.
The attacker told a Nova TV reporter the government was "blind and deaf to the laments of the people" before he was arrested.
Klaus, 71, is a popular figure in the central European EU country his second and final term ends next March.
It is thought that his sharp criticism of the euro, EU integration and efforts to halt global warming as well as his friendly stance towards Russia may have made him unpopular with some.