The Anomaly, also known as the Player, may or may not be a character in Toby Fox's Undertale. They serve as a driving force throughout the game, aiding Frisk on their journey throughout the Underground and manipulating the Underground itself.
As Undertale is a game that's very big on meta-commentary, the player themselves is just as much a character as anyone else inside the game, and the most powerful being in the context of the game as well. In any playthrough, the player is the one controlling Frisk and the being who makes every decision. At any moment the Anomaly can turn back time to the point where Frisk fell into the Underground, the only ones capable of overriding this power being Flowey after absorbing human souls and Chara after the latter reaches maximum LOVE. Most of the time, when the Anomaly resets time, only Frisk and Flowey are fully aware of the resets while everyone else has only vague recollections but under certain conditions even Frisk and Flowey can be made to forget. The only one with full immunity is Chara and only after they reach maximum LOVE.
There are only a handful of beings in Undertale that are aware of the Anomaly's influence and none of them know all of the details. While the Anomaly has been mistaken as Chara and Frisk by Flowey and Chara, respectively, it's unknown what Frisk knows and Sans isn't aware that the Anomaly is only a recent appearance and that it was Flowey who first caused the timeline anomalies.
The only beings capable of challenging the Anomaly directly are Chara, after they have reached maximum LOVE, and Flowey, after absorbing human souls. However, both are powerless against indirect influences as the Anomaly can edit the games files to alter the world as they see fit.
In a pacifist run, the Anomaly is a benevolent influence on Frisk who guides them through the underground, being helped by Chara who gives them advice on the best course of action. However, at the end of a pacifist run, it is possible to reset back to when Frisk fell into the underground, which by that point even Flowey no longer wants to do.
Should the Anomaly have done a genocide run before, the ending will be made sour by Chara who shows that they can possess Frisk at any time due to the Anomaly having sold Frisk's soul.
The influence of the Anomaly can be either benevolent of malevolent in this run. They can still be helping Frisk through the Underground, but not on a pacifist route due to mistakes on their part. However, if the Anomaly is experimenting at this point then they are trying to find out what would happen if they kill certain characters and spare other characters, under the justification that everyone can simply be brought back.
In a genocide run, the Anomaly is the hidden true main antagonist and at their most malevolent, playing an emotionally exhausting playthrough that calls them out on their actions every step of the way, is full of tedious level grinding, gives little pleasure in its fights due to almost all of those being incredibly easy while the two difficult boss fights are an exercise in frustration and permanently ruins any ending they can get for no other reason than that the Anomaly can and because it can, it must. At any point, the Anomaly can undo a genocide route by resetting unless they reach the point where Chara speaks to them.
After Flowey's and Asgore's deaths, Chara greets the Anomaly, thanking the latter for guiding and teaching them the importance of power. Chara then gives the Anomaly the option to erase the world or preserve it. Both options lead to the world being destroyed but saying to preserve it results in Chara betraying the player.
If the Anomaly returns to the Underground, it will be a featureless void. After ten minutes, Chara will speak to them again, knowing the Anomaly wants to go back and will call them out for thinking that they are above consequences. Chara will then offer to make a deal with the player, trading Frisk's soul in exchange for regaining their influence over the world. If the Anomaly refuses, Chara will say to stay there forever though if the player agrees then Chara will uphold their end of the deal.
If the player does a second run, even Chara will be disgusted by the Anomaly's actions, describing the Anomaly as having a perverse sentimentality that they can't understand and viewing the Anomaly as a different and worse kind of depravity than their own. Chara will then give the same options as the first Genocide run, erasing the world either way, however they will not prevent the Anomaly from resetting their second genocide run.