Officials gave no possible motive for the incident, which took place Wednesday evening.
"At 1545 GMT, a man stopped in a car in front of the consulate building and got out with a weapon in his hand," the official Saudi Press Agency quoted a police spokesman as saying.
"Security forces reacted... resulting in an exchange of fire that killed the assailant," it said, adding that the Nepalese guard later died of his wounds.
The shooting coincided with the final day of the hajj at nearby Mecca. More than 1.6 million foreign pilgrims arriving on planes and boats have streamed through coastal Jeddah en route to the rituals.
"Security investigations are still underway to ascertain the circumstances" of the incident, the police spokesman said.
The gunman's nationality has not been revealed. U.S. officials said no Americans were hurt and that the consulate had been secured.
"We offer our sincere condolences to the family and loved ones of the deceased local guards member," the State Department said in a statement in Washington.
"The consulate was appropriately locked down and no Americans were harmed in the attack," it said.
The United States was in touch with the kingdom as it starts its investigation, the statement added.
The U.S. consulate in the Red Sea city has been the target of previous attacks, including one on July 4, 2016 - American Independence Day - when a suicide bomber blew himself up.
In December 2004, the consulate was stormed by suspected Islamist extremists in an attack that left five non-American staff and contractors dead, as well as four gunmen.
That attack, claimed by Al-Qaeda's Saudi branch, was the first on a diplomatic mission in Saudi Arabia but one of a string of bombings and shootings in the kingdom at the time.
In recent times, Jeddah has been a hub of U.S. diplomatic activity as the United States and Saudi Arabia together try to mediate between warring generals in Sudan.
Secretary of State Antony Blinken visited the city earlier this month when he met Crown Prince Mohammed bin Salman, Saudi Arabia's de facto ruler.