The little girl in the white dress with sparkling trim sat in the velvet chair, swinging her feet back and forth. She wore white shoes and white tights and had baubles in her hair.

Before her, in Arlington National Cemetery on Friday, sat the silver coffin bearing the body of Petty Officer 2nd Class Mark A. Mayo, 24, who was killed last month at Naval Station Norfolk.

All around, lavender redbud trees and pink cherry trees were in bloom, while Mayo’s adult relatives who sat with the girl looked grief-stricken.

The little girl fidgeted as the chaplain prayed, and the sailors folded the flag, and the Navy officers with gold tassels and black ribbon on their swords knelt to say a word.

But as the family members rose and gathered around the coffin to bid Mayo a last farewell, the little girl began to wail inconsolably. A woman picked her up and carried her away.

Mark A. Mayo of Hagerstown, Md., was killed last month at the Norfolk Navy Base. (N/A/AP)

The Navy and Mayo’s family said an emotional goodbye Friday to the Naval security officer who has been hailed as a hero for protecting another sailor as a gunman opened fire aboard a ship at the base on March 24.

“When it looked like his shipmates were in extremis, he ran to the fight and was shot down,” Vice Adm. William F. Moran, the chief of Naval personnel, said after the service. “Petty Officer Mayo was clearly a hero to all of us, in the way he stepped in.

“He didn’t consider his own life,” Moran said. “He only considered the lives of his shipmates, and we’re awfully proud of that. And we’re awfully humbled by somebody who would put his life on the line.”

Before the ceremony, Mayo was posthumously awarded the Navy and Marine Corps Medal . It was presented to his family by Adm. Mark Ferguson, vice chief of naval operations. The medal is the highest non-combat decoration awarded for heroism by the Navy to sailors and Marines.

The Navy has said it still is investigating last month’s shooting, but has provided some details.

About 11:20 p.m. that Monday, Mayo, a native of Washington, was serving as chief of the guard and was alerted to a suspicious man walking toward the USS Mahan, a guided-missile destroyer moored at a pier.

Mayo pursued the man, who had managed to board the ship and disarm a watch officer. Mayo positioned himself between the gunman and the disarmed officer and in an exchange of gunfire was fatally shot by the assailant, the Navy said.

The Navy identified the gunman as Jeffrey Tyrone Savage, 35, of Portsmouth, a truck driver who had driven his tractor-trailer rig onto the base using a government-issued Transportation Worker Identification Credential.

The credential allows base access, but only in conjunction with other documents, the Navy has said, and Savage should not have been allowed on the base.

Savage, who was shot and killed by other guards, reportedly had a lengthy criminal record, including a conviction for manslaughter.

The guard who admitted Savage’s truck has been placed on administrative leave, and the Navy has beefed up screening of all delivery drivers showing a TWIC.

The Navy said it is investigating how Savage gained access to the base and whether the guard used proper procedures.

Mayo, who grew up in Hagerstown after his family moved from Washington, enlisted in the Navy in 2007 and had been stationed at Norfolk since 2011.

“His shipmates respected him, saw him as a model, an example,” Moran said. He was “one of those young men that we love to have in the Navy, and we hate to see a young man like that leave us so soon.”

The awarding of the Navy and Marine Corps Medal is rare, Moran commented: “It has to do with life-saving events . . . where you save another shipmate’s life, or the life of a civilian, or anyone else.”

“We see it from time to time for folks that have rescued people, saved their lives, or in this case stood in front of a bullet,” he said.

On Friday, as Mayo’s family and mourners from his base and the USS Mahan looked on, white-gloved members of the Navy Ceremonial Guard folded the flag that had covered his coffin.

Moran presented the flag to Mayo’s mother, Sharon Blair, who sat at one end of the row of seated mourners. Another flag was presented to Mayo’s father, Decondi Mayo, who sat at the other end wiping tears from his eyes.

In the middle sat the little girl in the white dress. Navy and cemetery officials in attendance did not know who she was, and Mayo’s list of survivors did not mention any offspring.

As the ceremony closed, a bugler sounded taps, and two boxes of white doves were released.