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.
It is not known how much they wanted their salaries to be increased by.
Experts are speculating that the protest was not as innocent as it first looked.
A former brigadier general told BBC Amharic that the security breach was “dangerous” and “an event which exposed the weakness of the military intelligence”.
Their demand was valid but the procedure soldiers followed violated military discipline, he said.
The general speculated that this was not a spontaneous protest. It might have been orchestrated by a group, he said.
He nonetheless thinks the prime minister deftly resolved the situation, even though the law clearly calls for disciplinary measures against the protesting soldiers.
Legal expert Dereje Zeleke agrees.
“This shows that the military and intelligence apparatus are not willing to serve the new commander-in-chief or the reform he represents,” he said.
He believes this was a message from a group resisting the many changes introduced by the prime minister since he came to power.
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.