They say a sniper fired three shots at the office of Prosecutor General Viktor Shokin late on Monday in Kiev, but bulletproof glass saved his life.
No-one was injured. No group has so far claimed responsibility for the attack.
Mr Shokin has been criticised for what his opponents say is his inability to bring any corruption cases to court.
He has also been accused of sabotaging the anti-corruption drive officially declared by Ukraine, as it seeks to forge closer ties with the EU following mass protests that toppled President Viktor Yanukovych in 2014.
The prosecutor general - who analysts say is an ally of President Petro Poroshenko - denies the claims.
He says no-one is immune from prosecution, pointing out that a prominent lawmaker has been recently stripped of his immunity following corruption allegations against him.
The apparent assassination attempt happened just days after another politician was detained in relation to what the authorities described as "a number of criminal cases".
Hennady Korban, the leader of the new Ukrop political party, was held over the weekend by Ukraine's security service.
Mr Korban, who played a key role in stopping the advance of Russian-backed separatists in the east into his native Dnipropetrovsk region, rejects the allegations.
He is also a close ally of regional tycoon Ihor Kolomoysky, who has been recently involved in a political tug-of-war with with President Poroshenko.
Some MPs have described Mr Korban's arrest as "politically motivated", accusing the authorities of using "selective justice" against their opponents.
Ukraine's officials have launched a criminal investigation into what they believe was an assassination attempt on the country's top prosecutor.