Abiy Ahmed was unhappy that soldiers had brought weapons and ordered them to do 10 press-ups.
They were among several hundred protesting soldiers who entered his office grounds to demand a pay rise.
The situation caused alarm, leading to road closures in the area and the internet to be shut off for hours.
Many Ethiopians wondered whether this amounted to a serious security breach, says BBC Amharic’s Jibat Tamirat.
However, the smiles on the soldiers’ faces as they performed the press-ups suggest the prime minister succeeded in defusing the situation amicably:
What happened exactly?
The soldiers began massing outside the presidential compound on Wednesday morning, causing a partial road block in the area, the BBC’s Amharic service reports.
Around half of them were armed with Kalashnikovs and sniper rifles.
They were told by the guards that they could not enter the sprawling grounds with their guns.
Contrary to previous reports, the soldiers were disarmed outside the compound. They were only allowed into the premises in the late afternoon and the road block was lifted.
After meeting the soldiers on Wednesday, Mr Abiy said he would “look into their complaints” but stressed that even civil servants had to make do with low salaries as the country had limited resources.
“We have to use the money for development purposes,” he said according to a statement. “We can pay everyone higher salaries but we will end up [with] no development.”
Who is Abiy Ahmed?
He came to power in April after three years of protest led by ethnic Oromos, who were demanding an end to what they considered their political and economic marginalization.
The prime minister, who is Oromo himself, has passed a series of massive reforms, making peace with neighbouring Eritrea and releasing the state’s tight grip on parts of the economy.
He has released thousands of political prisoners and unbanned groups, including the Oromo Liberation Front (OLF), which had been labelled terrorist organisations.