The Taliban claimed responsibility for the attacks, carried out while Mattis held meetings with President Ashraf Ghani and other Afghan leaders at the heavily fortified presidential palace. The attacks forced all flights to be canceled.
Several Afghans civilian were injured after one of the rockets hit a house near the combined civil and military airport, officials said.
The U.S. military and NATO use the airport, and it was not immediately clear if runways or aircraft were damaged. The barrage included at least 12 rockets fired from a house nearby, according to police.
The Taliban have fired rockets occasionally in the past on the airport, but Wednesday's attack was among the largest.
Speaking in a news conference with Mattis, Ghani said elite Afghan forces were deployed after the attack, which he described as "a sign of weakness, not strength" by the Taliban.
"It is a classic example of what the Taliban are up to right now," said Mattis.
Mattis with NATO chief Jens Stoltenberg spoke with Ghani about plans to strengthen Afghanistan's military as it faces a resurgent Taliban and factions backing the Islamic State.
Defense secretary visits to Afghanistan are tightly managed and planned well in advance, but not disclosed until after arrival.
Mattis travels abroad in a blue-and-white plane emblazoned with "United States of America" known as the E4B, but when visiting war zones he usually alternates to a lower-profile gray military jet.
In Afghanistan, there are several runways long enough for the defense secretary to land, including in Kabul itself and at Bagram Airfield north of the city. Defense secretaries have been known to land at Bagram and take helicopters down to the city, rather than landing in Kabul.
Militants have recently executed high-profile attacks seeking to cast doubt on the Afghan government's ability to defend its most fortified city. A suicide bomber killed at least 24 people July 24, wounding dozens more.
A week later, a suicide bomber blew open the gates to the Iraqi Embassy in a coordinated attack, with gunmen infiltrating the compound. At least two embassy workers were killed.
Those incidents followed a June 3 attack in the northern part of the city, where a trio of suicide bombers detonated explosives at a funeral procession, leaving at least 15 dead and 80 injured.
On May 31, a truck bomb parked near the diplomatic quarter killed at least 80 people and wounded hundreds more in a blast so massive a resident mistook it for an earthquake.