Lieutenant Colonel Arnaud Beltrame had offered himself in place of a woman whom the attacker was using as a human shield. The attacker, Redouane Lakdim, had been on a list of terror suspects since 2014.
Lieutenant-Colonel Arnaud Beltrame, 44, was the last person to be killed in the shooting spree that left four people dead on March 23, in the southwestern towns of Carcassonne and Trebes.
Beltrame had taken the place of a woman who had been held as the final hostage in a supermarket by 25-year-old gunman Redouane Lakdim, who pledged allegiance to the "Islamic State" (IS) group.
Macron compared Arnaud Beltrame's actions to those of France's World War II heroes and said his example would "remain etched in French hearts."
"To accept to die so the innocent can live — that is the essence of what it means to be a soldier," Macron said. "Others, even many who are brave, would have wavered or hesitated."
He had hoped he could negotiate with the attacker once customers and staff had been cleared from the supermarket, but Lakdim shot him and slit his throat.
Macron gave the eulogy at Les Invalides, a historic complex, which is home to France's army museum and a veterans' retirement center.
About 200 of Beltrame's colleagues from the gendarmerie, a national police force, which is part of the military, attended the ceremony in Paris.
Across the country, police stations paused for a minute's silence to honor their fallen colleague.
France: Police free hostages
01:13
A preventable attack?
Macron's government has been criticized by right-wing opponents who say the attack was preventable.
Lakdim had been on a list of suspected terrorists since 2014 and was being monitored. He also had previous convictions for drug use and handling a banned weapon.
Marine Le Pen, leader of the far-right National Front, accused the government of using the grief over Beltrame's death to "escape from its own incompetence and cowardice" in failing to combat Islamic extremism.
Prime Minister Edouard Philippe responded to the criticism on Tuesday in parliament saying, "Those who say ignorantly that this attack could have been avoided, those who promise people zero risk — I say to them, these people bear a heavy responsibility in speaking so casually."
Philippe dismissed right-wing proposals to introduce a complete ban on ultra-conservative Salafism or "preemptively" detain radical Islamists.
France already has a "legal arsenal" to "understand, monitor and sanction" extremists, Philippe said.
In France, more than 200 people have died in jihadist attacks over the past three years.
Terror attacks in France since 2015
France has been hit by several terror attacks since 2015, when "Islamic State" militants launched a brutal attack across Paris. Over the past three years, there have been other attacks, and close calls.
Image: Reuters/C. Hartmann
December 11, 2018: Strasbourg shooting
A gunman opened fire at a Christmas market in the eastern city of Strasbourg, home to the European Parliament. At least two people were killed and 12 injured. Prosecutors opened a terror investigation. France immediately raised its national security alert to its highest level in anticipation of copycat attacks.
Image: picture-alliance/dpa/aptn
May 12, 2018: Paris knife attack
A man wielding a knife attacks bystanders in a central neighborhood in Paris, killing one person and wounding another four. French prosecutors open a terror probe into the attack, citing witness accounts that the assailant shouted "Allahu akbar" ("God is greatest"). The militant "Islamic State" (IS) group claims responsibility for the attack, calling the knifeman one of their "soldiers."
Image: picture alliance/MAXPPP/O. Corsan
March 23, 2018: Trebes hostage crisis
An attacker claiming allegiance to IS perpetrates a string of violent crimes in the southern town of Trebes during the morning hours. He kills a man while stealing a car and then fires shots at police officers before entering a Super U grocery store, where he takes hostages. Police shoot dead the attacker. Four people are killed, including including policeman Arnaud Beltrame.
Image: Imago/PanoramiC/R. Gosselin
October 1, 2017: Marseille train station knife attack
A man fatally stabs two women at the Marseille train station. The perpetrator, Ahmed Hanachi, is shot dead by police on patrol. IS claims responsibility for the attack in a post by its news agency Amaq. In it, they call Hanachi one of the group's "soldiers." Two Interior Ministry officials resign after it is revealed that Hanachi was an undocumented immigrant who they had failed to detain.
Image: Reuters/J.P. Pelissier
April 20, 2017: Champs-Elysees police shooting
A gunman opens fire on police on the Champs-Elysees, Paris' most iconic boulevard. One police officer is killed and two individuals are injured before police shoot the gunman dead. A note praising IS is found next to the gunman's body. The terrorist group also claims responsibility. The attack occurs just days before the first round of the French presidential election. Security is tightened.
Image: Imago/Zuma Press/A. Freindorf
February 3, 2017: Machete attempt at Louvre
Soldiers shoot and severely injure a knife-wielding man outside the Louvre museum in Paris after he assails them. One soldier is lightly injured. The attacker had two further machetes in his backpack. A subsequent investigation reveals the Egyptian national had traveled to France from Dubai on a valid tourist visa. A Twitter account associated with the man's name refers to IS in posts.
Image: picture-alliance/AP Photo/K. Zihnioglu
July 26, 2016: Murder of Normandy priest
Two teens enter a church in Saint-Etienne-du-Rouvray, Normandy and slit the throat of an 85-year-old priest in front of five parishioners. Police shoot the 19-year-olds dead as they try to leave. IS takes responsibility and publishes a video of the teens pledging allegiance to the group. Many French Muslims attend the next Sunday's Mass to show solidarity with Catholics and condemn the attack.
Image: picture-alliance/dpa/C. Petit Tesson
July 14, 2016: Truck attack in Nice
On Bastille Day, France's national holiday, a truck drives through crowds in Nice that had gathered to watch the fireworks on a major seaside promenade. Before being shot dead by police, the driver kills 86 and injuries more than 400 others. IS claims responsibility, stating that the attacker had responded to IS calls to target civilians living in coalition nations fighting IS in Syria and Iraq.
Image: Reuters/E. Gaillard
November 13, 2015: Paris attacks
France's most deadly terror attack: IS jihadis armed with automatic weapons and explosives undertake coordinated attacks in Paris including at the Bataclan concert hall, the national stadium and various street cafes. The mass shootings and suicide bombings kill 130 people, injuring hundreds more. IS claims responsibility. Then-President Francois Hollande calls it an act of war by IS.
Image: Reuters/C. Hartmann
August 21, 2015: Thalys train tragedy averted
A deadly attack is averted: On a high-speed train from Amsterdam to Paris, a man opens fire with an assault rifle that subsequently jams. Other train passengers tackle the man, preventing deadly violence. Four are injured including the attacker. The assailant had been known to French security officials for past drug-related activities and statements in defense of radical Islamist violence.
Image: picture-alliance/dpa/P. Bonniere
June 26, 2015: Beheading, truck explosion near Lyon
Yassin Salhi beheads his boss and displays the head, along with two Islamic flags, on the gate outside a gas plant near Lyon. He also tries to blow up the factory by driving his van into the gas cylinders. The attempt fails, but unleashes a smaller explosion, injuring two. French authorities claim links between the man and IS. He commits suicide in prison.
Image: Reuters/E. Foudrot
January 7-9, 2015: Charlie Hebdo, Jewish supermarket attack
Two men with automatic guns storm the offices of satire magazine Charlie Hebdo, killing 12 and wounding 12 others. A different gunman kills a police officer the next day, then four more during a hostage-taking on January 9 at a kosher grocery. Police eventually shoot all three gunmen dead, but not before they claim allegiance to IS and al-Qaida.