Hamilton scored 3:04 into the game to put the Flames up 1-0, but Lewis, playing in his 500th NHL game, tied it 1-1 at 12:04 when Derek Forbort's point shot deflected off his leg and behind Elliott.
Iginla scored his first goal in Calgary in seven games as an opposing player to put Los Angeles up 2-1 with 45.8 seconds remaining in the second period.
Iginla played 16 seasons for the Flames and holds their records for games played (1,219), goals (525) and points (1,095).
"I don't know how many more games I'll play here, but this will be one that I will remember," the 39-year-old said. "It's special. Honestly, I really just don't know (whether he's going to retire). I go back and forth. I'll see how the year finishes and talk to my family and go from there."
Kopitar gave the Kings a 3-1 lead at 6:09 of the third period, and Carter extended the lead to 4-1 at 12:40.
It was the first game between the teams since Flames forward Matthew Tkachuk was suspended two games for elbowing Kings defenseman Drew Doughty on March 19. There were two fights and 40 penalty minutes in the first period. Iginla fought Flames defenseman Deryk Engelland after Tkachuk fought Kings defenseman Brayden McNabb.
"It's something that happened in the past," Tkachuk said. "You're done with it and you move forward."