Major General Abdulrahman bin Saad al-Shahrani, commander of the 18th Brigade, was inspecting troops deployed "on the front lines along the southern region when the post came under random enemy fire," said the military said in a statement carried by the official SPA news agency.
Shahrani was wounded in the attack and hospitalised, it said.
The statement did not say when the attack occurred but added that Shahrani had died of his injuries today.
More than 50 people, most of them troops, have been killed along the Saudi-Yemen border since the Riyadh-led military coalition began air strikes on Iran-backed rebels across the kingdom's impoverished neighbour in March.
But Shahrani is the most senior Saudi officer to be killed in cross-border fire.