So, from the beggining, Machina Kunagiri was Rem Tokimiya's best childhood friend, they grew up in the same village, but hadn't seen each other in seven years. They were both students at Suzako Peristylium, in Class Two, but neighther knew of the other's presence. Because of their great skill at magic, they were both transfered to Class Zero, and found out about the other.
Rem had a serious illness, ever since she was a child, and she knew that she would ocasionally die of it. Rem and Machina have some conversations during the game. In one, the subject is this illness, she has a coughing crisis, and he asks if her illness has gotten worse. She says that she has no idea what he's talking about, and that it's just ashtma. Machina gets frustraded, and asks why she's lying to him, if she does not trust him, but she assures it's not the case.
In another ocasion, Machina grieves the fact that he was not strong enough to protect the people from the village, and Rem says that they were only child, so there was nothing they could do. She asks Machina if he remembers the time that he vowed to become a strong soldier to protect her, and he says he remembers. Then, she asks, teasing him, if he remembers asking Rem to become his wife. He gets embarassed, and says that he was only a child, and Rem pretends to be offended.
Some time later, Machina finds out that Class Zero ans the commander were responsible for his brother, Izana's death, and gets really mad. He is offered a chance to leave the class, but denies, and promises on Izana's name that he will become stronger than Class Zero, in order to protect Rem. Class Zero is attacked by Celestia, who thinks that they killed the queen, and takes refuge in a forest. In this refuge, Machina yells at Ace and Queen over his brother's death. Rem stops him from storming off the place, but he insists on leaving to patrol the area, and promises Rem that he will protect her at all costs, before setting off.
Same as in the refuge, Machina gets the feeling of being observed more than once, and, as time passes, his behavior changes, he starts to spend long spaces of time away, and it worries everyone, especially Rem. It becomes really common for Machina to state that he will protect her.
After Milites's army is defeated, the two of them have a conversation. Rem says that she joined the academy to take part in Operation Apostle, to defeat Cid, an to become stronger. Machina says he joided for the same reasons, and adds that he has realized that he does not belong to Class Zero, because he hasn't been any help, he was the one who needed help. Rem says that he can count on both her and Class Zero, but he changes the subject, saying once more that he will protect her. Inspite Rem being against it, he leaves the school.
After he leaves, machina goes to Qun'mi, an I'Cie, and asks her for I'Cie power to protect Rem. She agrees, and gives him the power, along with a mask. Rem is also made a I'Cie of Suzako, to ensure the coming of Agito. They meet, and neighter knows who the other is. Believing that they are enemies, they fight. In the middle of the fight, though, his maks falls off, and Rem realizes who he is. She tries to stop her attack, and is impaled in Machina's rapier. He gets desperate and anguished when he sees that Rem's dying. He cries and apologizes, saying that he only became an I'Cie because he was afraid of losing her and being alone. Rem was about to die anyway from her illness, but says nothing. As she dies, she says to Machina not to forget her. He refuses himself to move, and just stays there, holding Rem's body, and ends up freezing, and Dying as well.
Just before the final battle with Cid, Class Zero finds their bodies. Machina and Rem speaks to them from the Crystal they're crystalized in, and says that they'll be with them in the fight. Their help is what makes them win. Arecia reviver Rem and Machina, but they arrive in the battle scene just to find out that everyone died while battling Cid. The scene ends with the who of them looking over the remains of Rubrum.
Years later, Machina is 67, married to Rem, and he writes down the events of the war, to ensure the events and Class Zetro would never be forgotten. He dies soon after, smiling, and the game ends.
But, there is also a alternative ending, a alternative future created by Arecia, where the war bever happened, and where Class Zero, Machina, Rem and Izana are all alive, having been given a second chance to live.