“They were carrying Kalashnikovs, hand grenades. One of them blew himself up and the others were killed by the security forces,” the head of the central Euphrates operations command, Qais Khalaf, said.
A member of the local council and a source at the provincial health directorate confirmed the death toll in the attack, which took place late on Sunday, and said at least 26 people were also wounded.
There was no immediate claim of responsibility for the attack but all recent suicide operations in Iraq have been claimed by the Islamic State (IS) jihadist group.
Ain al-Tamer is located about 50 kilometres (30 miles) west of the holy Shiite city of Karbala and lies on the edge of the province of Anbar, which was long a haven for jihadists.
Officials said the attackers started opening fire in a neighbourhood of Ain al-Tamer at around 1830 GMT on Sunday, although it was not immediately what their target was.
Five members of a same family were among the dead, according to a health official from Karbala province.
“The five terrorists were carrying lots of weapons and one of them blew himself up in the midst of our citizens,” said Farhan Jassem Mohammed, from the local council.
The military commanders said the attackers came from the Anbar desert to the west.
Karbala lies on the edge of the sprawling province of Anbar, which is overwhelmingly Sunni and has borders with Saudi Arabia, Jordan and Syria.
Iraq’s security forces have for months been battling IS fighters in Anbar, notching up key victories in the capital Ramadi and jihadist bastion Fallujah earlier this year.