Masaru is Okatani's childhood friend, but even more than that Masaru is Okatani's half-brother, at first they were friends completely unaware of that fact, Masaru lived a worse life as he was the bastard, his mother was Okatani's father's side piece.
Eventually Masaru and Okatani grew apart without finding their real relationship down, but Masaru did find out first, he was overcome with hatred for their deadbeat father, and with time Masaru came to reset Okatani too for he got all the good that comes with being legitimate son, what's more Okatani was attractive while Masaru was ugly, that prompted him to severely strive to improve his looks both naturally and through cosmetic surgery, Masaru was determined to get back at his father, and Okatani became a escape goat.
Ayaka grew to be very unsatisfied with her marriage with Okatani so Masaru saw an opportunity to seduce her as part of his plan to ruin Okatani's life, in the meantime we see Okatani fighting to win this divorce battle and win custody over Kokone, Okatani and his lawyers really do manage to build a strong case but the bias regarding mother's being the priority in taking the child starts to show, even with Okatani changing his entire life to make him a perfect always present figure for Kokone it seems he might lose her.
But despite all that Okatani has let go a lot of resentment over Masaru to a point Okatani ends up saving from a car accident near the end, this really becomes an eye opener for Masaru who realized Okatani always his good friend, his half-brother, why should he pay for their father's sins? This makes Masaru help Okatani in the court battle, he stops pretending to care about Ayaka and threatens her to reveal her divorce was actually malicious with all intent to ruin Okatani's life, she was no victim, this completely blindsided Ayaka, she gives up immediately and let's Okatani decide the course of their divorce.
Okatani wins Kokone's custody, but he doesn't rub on Ayaka's face, through this series he really becomes a nicer person, Okatani admits he wasn't a stellar husband, Ayaka was left alone for long periods of time raising Kokone by herself she really couldn't handle being that lonely, but Okatani remarks that still was no excuse to plot his demise, to cheat on him, Ayaka cries in a little self-realization that she really lost but Okatani will not take Kokone from Ayaka's life completely, he will allow her to periodically visit their daughter, in the end both Okatani and Ayaka see that this divorce only hurt unintended people in the end, their little Kokone, she was sweetie all this time but she crying as she realizes daddy and mommy are no longer together make Okatani and Ayaka realize they both made mistakes, Masaru goes away once his part is done, free of hatred, Okatani builds several love interests but he doesn't officially take any of them.