[verb て-form] + いた [verb て-form] + いました
ていた is the past of ている. It goes after the て-form of a verb and says the same things one step back in time: an action that was going on, a state that held, or a habit you used to have.
た reports an action as one event. ていた puts you in the middle of it, or in the state it left behind. With a verb of change, ていた is that state, which English often gives as "had done" or "was".
The English "-ing" does not carry over to these verbs: かれ彼はけっこん結婚していた is "he was married", not "he was getting married".
Over a stretch of past time, ていた is a habit that has since stopped.
"I knew" is しっていた知っていた, but "I didn't know" is しらなかった知らなかった.
The polite form is ていました. In casual speech the い drops and ていた becomes てた.