Mexican soldiers carrying automatic weapons interrupted the US Independence Day funeral of a US Marine and demanded that the Marine honour guard give up ceremonial replicas of rifles they carried.

Hundreds of friends and relatives packed a small cemetery for the funeral on Sunday of 22-year-old Juan Lopez, who was born in this sun-scorched farming town, immigrated to Dalton, Georgia, as a teenager and became a Marine.

He was killed in an ambush in Ramadi, west of Baghdad, on June 21.

Major Curt Gwilliam presented an American flag to Lopez's widow, Sandra Torres, who clutched a bouquet of yellow and white flowers while tears streamed down her face.

While the funeral demonstrated the close human ties of Mexico and the US, problems began moments after the start – leading to an expression of outrage by the US ambassador.

Four US Marines marched solemnly to the grave carrying an American flag and the colours of the Marine Corps. Two of the men had rifles that looked real, but could not be fired, strapped to their backs.

Four Mexican soldiers blocked their path, asking the four Marines and six others who had served as pallbearers to return to the car that had brought them to the funeral.

Several minutes of discussions by soldiers from both countries continued until a trumpet player began a rendition of taps and the funeral continued, despite the objections of the Mexican troops.

When the ceremony was complete, all the Marines on hand returned to a US Embassy vehicle and waited. Fourteen Mexican soldiers arrived to guard the premises.

About 40 minutes later, apparently under orders from a superior officer, the Mexican soldiers allowed the van to leave.

"I'm outraged that this would take away from the ceremony honouring US Marine Juan Lopez Rangel, whose family requested he be buried in his town of birth with full military honours," US Ambassador Tony Garza said.

A long-ago generation of Marines played a part in Mexico's deep suspicion of any foreign military force on its territory. The Marine Hymn's Halls of Montezuma refers to the 1847 capture of Mexico City.

The Mexican Defence Department banned plans for a 21-gun salute by Marines because Mexico's Constitution bans foreign soldiers from carrying firearms here.

Mexican soldiers at the funeral refused to comment, but US Embassy spokesman Jim Dickmeyer said they likely saw the rifle replicas and mistakenly thought the Marines were planning to fire a salute anyway.