Who = Used in the subject position in a sentence, so it’s the doer of an action
Whom = Used in the object position when who is not the subject of its own clause
Who and whom are also used as relative pronouns; used to link one clause to another
The man who beat Jack in the race has been shortlisted for the competition.
The man whom you beat in the race has been out of the competition.
The man whom you met at the park yesterday is coming to dinner.
Whom should we vote for in the coming elections? [Here whom is the object of vote for]
Formerly, when we needed the objective form of who, the use of whom was considered correct. However, in modern English, the objective form who is also considered Standard English. Even in formal writing, who is commonly used. Now, you can say that whom is probably going to be obsolete and outdated:
There were several contestants in the show who the organisers had turned away before.
Who should we vote for in the coming elections?
Who would you like to speak to? [Spoken English]
Be careful! Do not use who straight after a preposition – the preposition is usually moved at the end: The reporter (who) the Prime Minister gave interview to.
However, in formal writing, whom is more desirable: The reporter to whom the Prime Minister gave interview.
There are other types of sentences in which we don’t use who:
The contestants, many of who were already selected, were asked to go home and prepare for the final show. ✗
The protestors, many of whom had severe injuries, were taken into custody. [Here whom cannot be replaced by who] √
To whom would you like to speak? [Here whom follows the preposition to]
In formal style, a preposition before whom is preferred to leaving it ‘hanging’ at the end of the sentence:
It would be a good idea, if you could, to do some reference check about the people for whom you are going to work. [Formal]
It would be a good idea, if you could, to do some reference check about the people whom you are going to work for. [Informal]
Whom is advisable if you are writing anything formal especially in constructions with a preposition. However, whom is not correct here:
He is divorcing the woman whom he alleges had run off with another man. ✗
He is divorcing the woman who he alleges had run off with another man. √
Who in the above example is correct since the reporting verb allege has been inserted between the grammatical subject [woman] and the verb it governs [had run away]. If you remove he alleges, you will find the sentence wrong, because whom is wrongly used as the subject.
In short, whom is rarely used in informal language.
Whom do you believe had eaten up all the biscuits before the guests came? ✗
Who do you believe had eaten up all the biscuits before the guests came? √ [who is the subject of had eaten not the object of believe.]
With whom did you go to the movies? is correct but sounds like a teacher asking a student.
Who did you go to the movies with? is technically wrong but is the way we generally speak.
Here is the simple trick to make sure which one is correct – who or whom; replace he with him and vice versa. If he sounds better, who is right; if him sounds okay, whom is correct. That’s just for the reason that pronoun whom is used to represent the object of either a verb or a preposition:
He is the man whom we contacted to drive the kids to school. (We contacted him.)
He is the man who can drive the kids to school. (He can drive the kids to school.)
In the above two examples, the he/him formula works well.