user9209: Running out of time is a loss. Two players are both very low on time and quite far from a checkmate. What if one player makes some 'pointless' defensive moves to keep his clock running so that the other player, still trying to win, runs out of time.
I am new and I am asking because I have had opponents moving their king back around while I was there trying to do something and had no time left.
Is there some sort of rule that prevents my opponent from making useless moves while I try to win and run out of time?

user70: That's how it goes. Time management is an important part of tournament chess play.

user4362: There is an official Fide rule to prevent this kind of behavior ("flagging"). This rule however only holds in quickplay finishes of normal tournament games. In blitz managing the time better than your opponent is an integral part of the game. In online games (which mostly are blitz anyway) I have never seen this rule implemented (it's kind of tough without an arbiter).
Also note that this rule only allows you to claim a draw, to win you'll have to checkmate with the time still left to you. 
Article 10: Quickplay Finish
10.1
A ‘quickplay finish’ is the phase of a game when all the (remaining) moves must be made in a limited time.
10.2
If the player, having the move, has less than two minutes left on his clock, he may claim a draw before his flag falls. He shall summon the arbiter and may stop the clocks. (See Article 6.12.b)
a.
If the arbiter agrees the opponent is making no effort to win the game by normal means, or that it is not possible to win by normal means, then he shall declare the game drawn. Otherwise he shall postpone his decision or reject the claim.
(bold by me)

9209: <p>Running out of time is a loss. Two players are both very low on time and quite far from a checkmate. What if one player makes some 'pointless' defensive moves to keep his clock running so that the other player, still trying to win, runs out of time.</p>

<p>I am new and I am asking because I have had opponents moving their king back around while I was there trying to do something and had no time left.</p>

<p>Is there some sort of rule that prevents my opponent from making useless moves while I try to win and run out of time?</p>
 70: <p>That's how it goes. Time management is an important part of tournament chess play.</p>
 4362: <p>There is an <a href="https://www.fide.com/component/handbook/?id=124&amp;view=article" rel="nofollow">official Fide rule</a> to prevent this kind of behavior ("flagging"). This rule however only holds in quickplay finishes of normal tournament games. In blitz managing the time better than your opponent is an integral part of the game. In online games (which mostly are blitz anyway) I have never seen this rule implemented (it's kind of tough without an arbiter).</p>

<p>Also note that this rule only allows you to claim a draw, to win you'll have to checkmate with the time still left to you. </p>

<p>Article 10: Quickplay Finish</p>

<p>10.1
A ‘quickplay finish’ is the phase of a game when all the (remaining) moves must be made in a limited time.
10.2
If the player, having the move, has less than two minutes left on his clock, he may claim a draw before his flag falls. He shall summon the arbiter and may stop the clocks. (See Article 6.12.b)</p>

<p>a.
<strong>If the arbiter agrees the opponent is making no effort to win the game by normal means, or that it is not possible to win by normal means, then he shall declare the game drawn.</strong> Otherwise he shall postpone his decision or reject the claim.</p>

<p>(bold by me)</p>
