Mr Mashaal, who left the West Bank as a child and now leads the Islamic militant movement from Qatar, crossed the Egyptian border, kissed the ground, and was greeted by a crowd of Hamas officials and representatives of Hamas' rival Fatah party.
Mr Mashaal, 56, was also welcomed by a group of Palestinian children of Gaza militants killed by Israel in recent years, wearing military-style uniforms. Thousands of Hamas supporters lined the streets as Mr Mashaal and Gaza Prime Minister Ismail Haniyeh drove by, waving and flashing victory signs.
That the visit took place at all is a window on the changing climate of the Middle East and the balance of power among the factions and nations.
Hamas has received a boost from the rise of its parent movement, the fundamentalist Muslim Brotherhood, following Arab Spring revolts - especially in Egypt. Deposed Egyptian President Hosni Mubarak barely tolerated Hamas, cooperating with Israel on a blockade of Gaza after Hamas overran it in 2007.
Israel, along with the US and European Union, lists Hamas as a terror organization because of its history of attacks, including suicide bombings, against Israelis. Controlling most entrances to Gaza, Israel prevented most prominent diplomats from entering the territory after the violent Hamas takeover.
Egypt's new Brotherhood-dominated regime has welcomed Hamas leaders, negotiating a truce to end an eight-day flare-up between Hamas and Israel last month. Hamas trumpeted that as a victory, despite the new wave of death and destruction in the territory under its control in Israeli airstrikes, meant to stop daily Palestinian rocket attacks.
More significantly, in another precedent-setting series of events, the Egyptian prime minister and other foreign diplomats visited Gaza during the fighting, crossing in from Egypt, just as Mr Mashaal did on Friday.
"I have been dreaming of this historic moment my entire life, to come to Gaza," Mr Mashaal told reporters as he stood alongside senior Hamas member Mousa Abu Marzouk and Hamas Prime Minister Ismail Haniyeh. "I ask God to give me martyrdom one day on this land."
Mr Mashaal appeared before the charred car of Hamas militant chief Ahmad Jabari, assassinated by Israel at the beginning of last month's round of violence. The eight-day conflict was the bloodiest round of Israel-Gaza fighting in four years. Militants launched hundreds of rockets on Israel and Israeli warplanes targeted an equal number of Hamas targets.
Mahmoud Zahar, senior Hamas member, said Mr Mashaal's first visit was in celebration of Hamas' gains in the latest round of fighting.
"He should return after a victory," Mr Zahar said. "This return came after a victory."
Mr Mashaal's visit, though widely cheered, is nevertheless sensitive because of Palestinian political infighting. Mr Mashaal, considered more pragmatic than Hamas' Gaza-based hard-line leaders, forged a reconciliation agreement with Palestinian President Mahmoud Abbas, who rules the West Bank. But the Gaza-based leadership, unsupportive of the agreement, has held up implementing it.
On Friday Mr Mashaal asked aides to remove a red carpet laid out for him and refused an honour guard ceremony for his arrival. He appeared sensitive to the fact that Abbas still has not visited Gaza since Hamas wrested control of Gaza from his Fatah Party.
Palestinian officials in the West Bank expressed hope that Mr Mashaal's visit would help finalize the Palestinian political unity deal.
Israel, which is reluctantly coming to terms with the shifting Palestinian power balance, mostly kept silent on the visit. A Foreign Ministry spokesman said Israel did not differentiate among various Hamas leaders.
"Hamas is Hamas is Hamas," said the spokesman, Yigal Palmor.
Fifteen years ago, Mr Mashaal was nearly assassinated in Jordan by Israeli agents who squirted a deadly poison in his ear, narrowly escaping after the US forced Israeli Prime Minister Benjamin Netanyahu, then serving his first term as premier, to provide the antidote.
Now a bolstered Mr Mashaal appears in Gaza undeterred by neighbouring Israel. Mr Mashaal referred to the assassination attempt by "the foolish Netanyahu," saying, "God was stronger than him and his conspiracy."
Thousands of masked Hamas militants deployed throughout Gaza to protect Mr Mashaal's convoy, with rocket propelled grenades, assault rifles and anti-aircraft weaponry in tow.
During Friday's visit, which was timed for the 25th anniversary of Hamas' founding, Mr Mashaal also paid homage at the house of the group's spiritual leader Ahmed Yassin, who was paralyzed in a childhood accident and killed by a missile fired from an Israeli helicopter on March 22, 2004.
The assassination came at a time of heavy Israeli-Palestinian fighting that saw Hamas suicide bombers detonate their explosives inside buses, restaurants and other public places across Israel.
"The resistance was launched from this humble house, Yassin the giant of Jihad operated from here. We pledge to continue his path," Mr Mashaal told reporters at Mr Yassin's house, which has been turned into a museum of sorts. Mr Yassin's sons and grandchildren greeted Mr Mashaal, who stopped for a few moments by Mr Yassin's broken wheelchair.