The three men, who were in a car, tried to enter the temple's parking lot when a plainclothes policeman forced it to stop, Egypt's Tourism Ministry said. Security forces confronted them, and two were killed: one died when he detonated the explosives he was carrying, and another was shot in the head, the Interior Ministry added.
The third militant was injured.
Egypt's Health Ministry said in a statement that five people were injured, including civilians.
"The policeman who stopped the vehicle sustained minor injuries, but due to his heroic actions, many other potential victims were saved and thankfully no tourists were harmed," Tourism Minister Khaled Rami said.
Typically, thousands of tourists visit Luxor and Karnak Temple daily.
This is the first deadly attack on a Luxor tourist site since 1997, when gunmen killed 62 people -- most of them international tourists.
Not just government targets
The targeting of tourist sites represents a major escalation by Islamist militants in Egypt.
Last week, gunmen shot and killed two police officers in an attack a few hundred meters from the Great Pyramids of Giza, the Interior Ministry said.
Previously, militants, including the ISIS-aligned Ansar Beit Al Maqdis, mostly targeted Egyptian government officials and security forces. But four people were killed and 14 wounded when Ansar Beit Al Maqdis targeted a bus of South Korean tourists traveling from Egypt's Sinai Peninsula into Israel in February 2014.
Militants have killed hundreds of policemen and soldiers since the overthrow of Islamist President Mohamed Morsy in July 2013.
Recently, they expanded their targets to include judges.
Wednesday's attack coincided with the signing of the African Tripartite Free Trade Agreement in Sharm el-Sheikh, Egypt. Several African leaders, including Egyptian President Abdel Fattah el-Sisi, are attending the summit in the Sinai Peninsula, hundreds of kilometers away from the site of Wednesday's attack.
In a post last month on its official Arabic website, the Muslim Brotherhood appeared to endorse a call to arms by urging followers to "resist this coup by all means until the fall of the regime" and asserted the "legitimate right to self-defense."
Security forces have arrested anyone belonging to or accused of working with the Brotherhood, a group designated by Egypt as a terrorist organization. Hundreds of Islamists and their supporters have been killed in the crackdown.
The Egyptian government has been trying to lure back tourists for the summer high season.
Tourism represents 11.3% of Egypt's gross domestic product and 19.3% of its foreign currency revenues, Egypt's State Information Services says.
"The government of Egypt places the highest priority on the safety of tourists in our country," said Rami, the tourism minister. "We have enhanced security measures in place at all our sites, and we continue to take every possible measure to ensure that no harm comes to anyone visiting Egypt."