Ex Machina tells the story of a computer coder, Caleb (Domhnall Gleeson), who wins the chance to spend a week at the house in the mountains belonging to Nathan (Oscar Isaac), the CEO of the company he works for.
Caleb is airlifted into the middle of a reserve owned by Nathan, and is then left to make his way on foot through the woodland to the house. Once he arrives at the house, Caleb is greeted by an automated system that issues him with a key card and lets him enter the property. Caleb is initially left to wander the house confused, but eventually finds Nathan working out.
Nathan shows Caleb around and then tells him that the key card will only open certain doors in the "facility", before making him sign the "mother of all NDAs". Nathan claims that he wants Caleb to treat him as a friend, but their relationship is awkward and tense.
Later that day, Nathan introduces Caleb to his "experiment" and says he wants Caleb to spend the next week performing a live 'Turing Test'. The subject is a fully humanoid artificial intelligence called 'Ava' (Alicia Vikander). She has a face, hands and feet of flesh, but the rest of her body is clearly that of a cyborg / robot / android.
That night, Caleb discovers that the TV in his room is actually a CCTV network that allows him to watch Ava in her habitat. There is suddenly a blackout, and Caleb goes to find Nathan. He eventually locates him, with Nathan drunk and in a petulant mood. Nathan says that the power cuts happen on a regular basis and that he is "looking into it."
The next morning Caleb is awoken by Kyoko (Sonoya Mizuno), a Japanese girl who does not speak or engage with him in any way. He later learns that she does not speak English because it allows Nathan to "talk shop" and not be concerned about information leaking.
Caleb meets with Ava again and she starts to flirt with him. There is a power cut and Ava suddenly warns Caleb not to trust Nathan. We soon learn that it is Ava who has been triggering these blackouts. That evening Nathan is abusive to Kyoko when she spills some wine on Caleb.
As Caleb and Ava spend more time together, the two form a bond which peaks with Ava dressing herself in clothes to appear more human to Caleb. He is confused and excited by this, and tells Nathan that he thinks this is a trick, that Ava has been programmed to flirt with him. An enraged Nathan shouts at Caleb and then shows him his lab where Ava was created, explaining to him how her mind operates and that he has been using his own software to map the faces, voices and habits of the world population to build a fully self-evolving brain.
One evening Nathan gets extremely drunk and Caleb escorts him to his room. There he sees some cupboards and is able to catch a glimpse of Nathan's 'observation' room.
One evening during a shave, Caleb sees CCTV footage of Nathan entering Ava's room and ripping up a drawing she has been creating. Caleb begins to suspect Nathan of being abusive.
In a one on one, Caleb asks Nathan what he will do with Ava if she fails the test, and he says she will be "updated" and this will result in her memory being wiped. This is a visibly upsetting prospect for Caleb. Nathan gets very drunk and passes out. Caleb steals Nathan's key card and enters the 'observation' room. Inside he finds footage on Nathan's computer that shows he has been building various female AIs over a period of time.
Caleb goes into Nathan's room and finds Kyoko laying naked on the bed. He opens the cupboards in Nathan's room and finds all the destroyed and deactivated robots hanging up. Kyoko pulls the skin from her face to reveal that she is also an AI. Caleb leaves the room just in time to find Nathan stumbling around drunk. He palms Nathan's key card from the floor and pretends Nathan had dropped it.
In his final meeting with Ava, Caleb encourages her to trigger a power cut and he reveals to her his plan to help her escape. He intends on getting Nathan drunk one last time and then locking him in his room.
The next morning Nathan and Caleb share polite conversation, and in it Nathan confirms a helicopter will arrive the next morning to pick Caleb up. Caleb offers a drink to Nathan in toast, but he refuses and reveals to him that when he entered Ava's room to destroy the picture, he hid a battery operated camera in there, and he knows Caleb's plan. Nathan admits to Ava being geared towards Caleb's desires based upon information taken from his internet searches, etc. Nathan tells Caleb that Ava is not in love with him, that she is using him, he celebrates this as confirmation that she is a true AI, deeming the test a success.
There is a black out and Caleb says he had already put his plan into action when he stole Nathan's key card, and that during lock down the system had been re-routed to open every door. Nathan knocks Caleb unconscious and leaves to kill Ava.
Ava and Kyoko share a secret conversation, Ava then attacks Nathan and Nathan retaliates by destroying Ava's hand. As he drags Ava back to her room Kyoko stabs Nathan in the back with a sushi knife. Nathan breaks Kyoko's face apart and is then stabbed a second time by Ava. As Nathan dies he seems somewhat amazed by the irony. Ava locks Caleb in Nathan's room and then proceeds to raid the cupboards containing the old AIs. She takes skin and clothes to establish herself as almost human. She leaves Caleb locked in the facility and makes her way to Caleb's pickup point, where she is airlifted out of the area and into human society.