Ali Larijani, speaker of parliament and one of the major figures in the Islamic Republic, met Mashaal and several high level officials from Hamas at the Iranian embassy in the Syrian capital, witnesses said.
The meeting stretched into the early hours of Thursday, with no details emerging from the deliberations. Larijani earlier met leaders of Islamic Jihad, a smaller Palestinian group with close links to Iran.
Iran and Syria are the major backers of Hamas, and Syria hosts members of Hamas' exiled leadership, including Mashaal.
The two countries have influence on Hamas but little is known about what advice Tehran and Damascus have been giving Hamas in the current crisis.
Larijani also met President Bashar al-Assad on Wednesday to discuss the "dangerous situation" in Gaza, the official Syrian news agency said. He is the second Iranian official to visit Syria since Israel's ground invasion of Gaza began on Saturday.
Saeed Jalili, a senior Iranian security official, met Hamas and Islamic Jihad officials in Damascus this week, before Egypt announced a plan for a truce in Gaza brokered by France.
Hamas said it was looking at the plan, which aims to prevent Hamas rearming through smuggling tunnels from Egypt and tackles Hamas's demand for an end to Israel's blockade on Gaza, a major reason cited by Hamas behind its decision not to renew a truce with Israel last month.