user5152: Let's say two miners created 2 different blocks and broadcast them into the network. Now some clients see blockchain 1 and other blockchain 2 which are different from each other.
I would like to understand technically as possible how in the end the majority of clients will continue with only single chain and the other be abandoned?
Why will they choose one over the other?
I would like to believe this is done automatically by the clients / miners without human touch, only by some kind of coded logic. That logic is what I'm after.    
Related question: What happens to extinct blockchains, and transactions inside of them?

user8717: This is explained in the Bitcoin paper:

Nodes always consider the longest chain to be the correct one and will
  keep working on extending it. If two nodes broadcast different
  versions of the next block simultaneously, some nodes may receive one
  or the other first. In that case, they work on the first one they
  received, but save the other branch in case it becomes longer. The tie
  will be broken when the next proof-of-work is found and one branch
  becomes longer; the nodes that were working on the other branch will
  then switch to the longer one.

The idea is that it's quite rare for the network to find 2 different blocks at around the same time. If it happens, you'll have peers working on one chain and others on the other. It becomes even rarer for it to happen in succession, so it's just a matter of time that the network will converge on a single chain.

user2306: You're looking for CBlockIndexWorkComparator, which operates by three rules. The rules are applied one at a time, and if a rule leads to a tie, then the next rule is applied.

Which blockchain has the most work? 
Which one was received first? (This can be different for different clients, which is why the previous rule is applied first.)
Which one has a larger pointer address? (This is largely random, and different for different clients.)


5152: <p>Let's say two miners created 2 different blocks and broadcast them into the network. Now some clients see blockchain 1 and other blockchain 2 which are different from each other.<br>
I would like to understand technically as possible how in the end the majority of clients will continue with only single chain and the other be abandoned?<br>
Why will they choose one over the other?<br>
I would like to believe this is done automatically by the clients / miners without human touch, only by some kind of coded logic. That logic is what I'm after.    </p>

<p>Related question: <a href="https://bitcoin.stackexchange.com/questions/12462/what-happens-to-extinct-blockchains-and-transactions-inside-of-them/">What happens to extinct blockchains, and transactions inside of them?</a></p>
 8717: <p>This is explained in the <a href="https://bitcoin.org/bitcoin.pdf" rel="nofollow">Bitcoin paper</a>:</p>

<blockquote>
  <p>Nodes always consider the longest chain to be the correct one and will
  keep working on extending it. If two nodes broadcast different
  versions of the next block simultaneously, some nodes may receive one
  or the other first. In that case, they work on the first one they
  received, but save the other branch in case it becomes longer. The tie
  will be broken when the next proof-of-work is found and one branch
  becomes longer; the nodes that were working on the other branch will
  then switch to the longer one.</p>
</blockquote>

<p>The idea is that it's quite rare for the network to find 2 different blocks at around the same time. If it happens, you'll have peers working on one chain and others on the other. It becomes even rarer for it to happen in succession, so it's just a matter of time that the network will converge on a single chain.</p>
 2306: <p>You're looking for <a href="https://github.com/bitcoin/bitcoin/blob/1d9d314573ee48f6f51107265f1cf1fa9e36c998/src/main.cpp#L91" rel="nofollow noreferrer">CBlockIndexWorkComparator</a>, which operates by three rules. The rules are applied one at a time, and if a rule leads to a tie, then the next rule is applied.</p>

<ul>
<li>Which blockchain has <a href="https://bitcoin.stackexchange.com/a/939/2306">the most work</a>? </li>
<li>Which one was received first? (This can be different for different clients, which is why the previous rule is applied first.)</li>
<li>Which one has a larger pointer address? (This is largely random, and different for different clients.)</li>
</ul>
