BRUSSELS — Belgian soldiers fatally shot a man who attacked them with a knife in central Brussels on Friday night, according to the Belgian authorities, who were treating the attack as a terrorist episode.

About the same time, two London police officers suffered minor injuries outside Buckingham Palace when they overpowered a man with a knife.

The Brussels attacker, who was not named, died in a hospital, the Belgian authorities said. Two soldiers were lightly wounded.

On Saturday, the Islamic State claimed responsibility for the attack through its news agency, Amaq.

Ester Natus, a spokeswoman for the federal prosecutor, responsible for terrorism investigations in Belgium, said that the man shouted “Allahu akbar” twice during the attack. The prosecutor’s office said it had opened on investigation “on suspicion of attempted terrorist murder.”