The imparfait is used to describe situations in the past.
(There is a separate section on the difference between the passé composé and the imparfait.)

Hier, je faisais mes devoirs quand ma meilleure amie est venue me voir.
Yesterday I was doing my homework when my best friend came to see me.

Le roi chassait quand la Révolution a commencé.
The king was hunting when the Revolution started.

The imparfait is formed from a stem and a set of endings.

The stem is the present tense 'nous' form stem:

porter nous portons port-
finir nous finissons finiss-
répondre nous répondons répond-
aller nous allons all-
écrire nous écrivons écriv-

The only exception is 'être', whose stem is irregular: ét-

The endings are:

je -ais nous -ions
tu -ais vous -iez
elle, il, on -ait elles, ils -aient

For example:

porter (to carry, to wear) is a regular -er verb

the 'nous' form is 'portons', so the stem is port-

porter
je portais   nous portions
tu portais vous portiez
elle, il, on portait elles, ils portaient

Special cases

Verbs ending in -ger or -cer

Verbs such as 'manger', which end in 'ger', require an extra 'e' in the forms where the ending begins in an 'a': 'je mangeais', 'tu mangeais', 'il mangeait' and 'ils mangeaient' (but 'nous mangions', 'vous mangiez') (Why?)

Verbs such as 'commencer', which end in 'cer', take a c cedilla ('ç') in the forms where the ending begins in an 'a': 'je commençais', 'tu commençais', 'elle commençait', 'elles commençaient' (but 'nous commencions', 'vous commenciez') (Why?)

Étudier, rire, and others

Some verbs have a stem that ends in an 'i'. This means that the 'nous' and the 'vous' forms will have a double 'i' where the stem meets the ending:

Nous étudiions quand le prof est entré.

Est-ce que vous riiez de moi?

Don't be deterred! This is quite normal in French, even though it looks a little odd to native English-speakers.