You already know the core modal verbs in the present tense — kann, muss, will, and so on. But how do you talk about an ability, obligation, or wish that happened in the past, like I had to work or I couldn't come? This is where German produces one of its strangest structures.
Normally, any German verb in the Perfekt tense takes haben or sein plus a Partizip II, as in Ich habe gearbeitet. But when a modal verb such as müssen or können appears together with another main verb, the rule changes completely: instead of taking its usual Partizip II form (like gemusst), the modal verb stays in its plain infinitive form and moves to the very end of the sentence, after the main verb, which is also left in the infinitive. This is called the double infinitive (doppelter Infinitiv):
Ich habe gestern arbeiten müssen — not Ich habe gearbeitet gemusst.
Notice the order: haben stays in second position as usual, and then two infinitives stack up at the end — the main verb first, the modal verb last. This reversed order, where the modal verb, logically the most important piece, ends up last, trips up many learners, especially when their own language would put the equivalent of had to right at the front.
The reassuring part: in everyday spoken German, native speakers mostly avoid this heavy construction and prefer the simple past, Präteritum: musste, konnte, wollte, durfte, sollte, mochte. It's easy to form — verb stem plus -te- plus a personal ending, and any umlaut the verb had in the present tense disappears: kann becomes konnte, will becomes wollte. So instead of the long sentence above, Ich musste gestern arbeiten says the same thing, and it's by far the more common choice, in speech and even in writing.
Watch out for one small but frequent trap: mochte (liked, from mögen) has nothing to do with möchte (would like, a polite present-tense form), despite looking almost identical. One is simple past, the other a polite present — never swap one for the other.