ありがとうございます is used before the thankful thing(favor) has not completed.
ありがとうございました is used after the thankful thing has already completed.
男<おとこman>: どうしましたか。What happened with you?
女<おんなwoman>: エンストしちゃったみたいなんです。It seems that the engine has stopped.
男: ちょっと見<み>てみましょうか。Shall I check it a little?
女: ほんとですか。ありがとうございます。Really? Thank you.
(しばらくして after a while)
男: エンジンを掛<か>けてみてください。Please try to run the engine.
女: はい。Yes.
(エンジン音<おん>engine sound)
女: あっ、掛かりました!Oh, it works well!
女: 助<たす>かりました。本当<ほんとう>にありがとうございました。You were very helpful. Thank you very much.
※We(Japanese) say ありがとうございました not only immediately after a kind act, but also later again. In the above situation, when she saw him next time, she should say to him 先日<せんじつ>はありがとうございました<Thank you very much (for your kindness) the other day> .
※ありがとうございます is also used after the thankful thing has already completed when the act is an usual thing(habit) (of a regular customer).
客<きゃくcustomer >: これをください。I'll take this.
店員<てんいんsalesclerk >: はい、ありがとうございます。Yes, thank you. 4,320円<えん>になります。It'll be 4,320 yen.
(店員が代金<だいきん>を受<う>け取<と>り、客に品物<しなもの>を渡<わた>すThe salesclerk receives the price, and she hands the article to the customer)
客: じゃ、どうも。See you.
店員: 毎度<まいど>/いつもありがとうございます。Thank you every time.