user-1: Proof of work in spam
I understand very well how proof of work is used to prevent email spam for example. Reasoning is since computing the right hash (e.g. with predefined number of zeros for example) for a single email is expensive, it will not be desirable for people sending spam to million recipients to compute that hash for each email. Now this reasoning makes perfect sense.
Proof of work in bitcoin
However, I don't know how the proof of work system is used in bitcoin, more precisely:

which problem does it try to solve
and more importantly how does it solve this

Can someone explain it (in layman terms)? 

user44760: which problem does it try to solve?
Imagine a P2P system in which all nodes are connected. Now, any peer can propose a block(these set of transactions) and say that it is valid and should be added to blockchain(the ledger containing these blocks). Now, the question which peer proposes this new block? . If we randomly choose a peer to propose this block, it is vulnerable to sybil attack(create multiple nodes).
Enter PoW(Proof of Work): We approximate selecting a random node by instead selecting nodes in proportion to a resource that we hope that nobody can monopolize. What does that mean? Well, if that resource that we're talking about is computing power, then it's a proof-of-work system where we somehow select nodes in proportion to their computing power. 
I would call PoW is a sybil-attack resistant method for choosing a block to propose the next block. Just like SPAM protection, it is SPAM protection from choosing a peer to propose the next blocks. Other parts such as block rewards, double-spend etc are related to game-theoritic incentives. I hope you can relate it with email spam protection
EDIT:
In SPAM protection: you prevent sender from making a DOS attack on servers by forcing them to provide a valid PoW for every message. This prevents from DoS attacks of many sybils. Here, you choose only the valid messages which are to be processed by your server. You pick winners(valid messages) from spam you recieve.
In bitcoin: It is a method for deciding which block should be the next block. You choose winners(only 1, the first one to provide valid PoW) from the many blocks which peers may propose. 

user85: To have a useful payment system, if I have some asset the system supports, I have to be able to send it to Alice if she is a user of that system. And I also have to be able to send it to Bob if he is a user of that system. But if I can do both of these things, the system stops being useful. So, for bitcoin, somehow sending bitcoins to Alice must prevent me from sending them to Bob and vice versa.
Traditionally, this would be accomplished by a central authority. For example, my bank can process checks in the order it receives them, approving them if I have a sufficient balance and deducting that amount from my balance. The bank can prevent me from sending the same money in two places. But bitcoin has no central authority.
Bitcoin's solution has several pieces.
First, it groups transactions into blocks. Second, it chains blocks into a blockchain.
Third, it has rules for what is or is not a valid blockchain. For example, a chain that includes two conflicting transactions is not valid. So, in my example, either a blockchain can include my payment to Alice or my payment to Bob, but not both. This works because all transaction and state information is public, so nobody would ever accept any blockchain with conflicting transactions unless they chose to foolishly harm themselves.
But we still have one problem left -- how do we ever get everyone to agree on which blockchain is valid if there's one that includes the payment to Alice and one that includes the payment to Bob? That's where proof of work (mining) comes in.
It consists of two steps:
1) To add a block to the blockchain, you must do a very large amount of computational work.
2) You will be rewarded with bitcoins for doing this large amount of work, but only if the blockchain that contains the block you added becomes the one everyone agrees on.
And lastly, one more rule: We agree on that valid blockchain that has required the most computing power to generate.
Under reasonable conditions, this assures that everyone will eventually agree which of the two transactions is valid. Miners are incentivized to build on the longest, valid block chain they know of, because that gives them the best chance of being rewarded. Thus longer chains will tend to get longer and shorter chains will tend to be ignored. Eventually, one chain will be so much longer than every other chain that we everyone is mining on top of it and nobody is mining on top of the other and there is no chance the shorter chain will ever be longer.
Once that happens, and the longer chain contains one of my two transactions sufficiently deep in the chain, we can all agree which way my bitcoins go. And no central authority is needed.

-1: <p><strong>Proof of work in spam</strong></p>

<p>I understand very well how proof of work is used to prevent email spam for example. Reasoning is since computing the right hash (e.g. with predefined number of zeros for example) for a single email is expensive, it will not be desirable for people sending spam to million recipients to compute that hash for each email. Now this reasoning makes perfect sense.</p>

<p><strong>Proof of work in bitcoin</strong></p>

<p>However, I don't know how the <strong>proof of work</strong> system is used in bitcoin, more precisely:</p>

<ul>
<li>which problem does it try to solve</li>
<li>and more importantly <strong>how</strong> does it solve this</li>
</ul>

<p>Can someone explain it (in layman terms)? </p>
 44760: <p>which problem does it try to solve?</p>

<p>Imagine a P2P system in which all nodes are connected. Now, any peer can propose a block(these set of transactions) and say that it is valid and should be added to blockchain(the ledger containing these blocks). Now, the question which peer proposes this new block? . If we randomly choose a peer to propose this block, it is vulnerable to sybil attack(create multiple nodes).</p>

<p>Enter <strong>PoW(Proof of Work)</strong>: We approximate selecting a random node by instead selecting nodes in proportion to a resource that we hope that nobody can <strong>monopolize</strong>. What does that mean? Well, if that resource that we're talking about is computing power, then it's a proof-of-work system where we somehow select nodes in proportion to their computing power. </p>

<p>I would call PoW is a <strong>sybil-attack resistant</strong> method for choosing a block to propose the next block. Just like SPAM protection, it is SPAM protection from choosing a peer to propose the next blocks. Other parts such as block rewards, double-spend etc are related to game-theoritic incentives. I hope you can relate it with email spam protection</p>

<p>EDIT:
In SPAM protection: you prevent sender from making a DOS attack on servers by forcing them to provide a valid PoW for every message. This prevents from DoS attacks of many sybils. Here, you choose only the valid messages which are to be processed by your server. You pick winners(valid messages) from spam you recieve.</p>

<p>In bitcoin: It is a method for deciding which block should be the next block. You choose winners(only 1, the first one to provide valid PoW) from the many blocks which peers may propose. </p>
 85: <p>To have a useful payment system, if I have some asset the system supports, I have to be able to send it to Alice if she is a user of that system. And I also have to be able to send it to Bob if he is a user of that system. But if I can do both of these things, the system stops being useful. So, for bitcoin, somehow sending bitcoins to Alice must prevent me from sending them to Bob and vice versa.</p>

<p>Traditionally, this would be accomplished by a central authority. For example, my bank can process checks in the order it receives them, approving them if I have a sufficient balance and deducting that amount from my balance. The bank can prevent me from sending the same money in two places. But bitcoin has no central authority.</p>

<p>Bitcoin's solution has several pieces.</p>

<p>First, it groups transactions into blocks. Second, it chains blocks into a blockchain.</p>

<p>Third, it has rules for what is or is not a valid blockchain. For example, a chain that includes two conflicting transactions is not valid. So, in my example, either a blockchain can include my payment to Alice or my payment to Bob, but not both. This works because all transaction and state information is public, so nobody would ever accept any blockchain with conflicting transactions unless they chose to foolishly harm themselves.</p>

<p>But we still have one problem left -- how do we ever get everyone to agree on which blockchain is valid if there's one that includes the payment to Alice and one that includes the payment to Bob? That's where proof of work (mining) comes in.</p>

<p>It consists of two steps:</p>

<p>1) To add a block to the blockchain, you must do a very large amount of computational work.</p>

<p>2) You will be rewarded with bitcoins for doing this large amount of work, but only if the blockchain that contains the block you added becomes the one everyone agrees on.</p>

<p>And lastly, one more rule: We agree on that valid blockchain that has required the most computing power to generate.</p>

<p>Under reasonable conditions, this assures that everyone will eventually agree which of the two transactions is valid. Miners are incentivized to build on the longest, valid block chain they know of, because that gives them the best chance of being rewarded. Thus longer chains will tend to get longer and shorter chains will tend to be ignored. Eventually, one chain will be so much longer than every other chain that we everyone is mining on top of it and nobody is mining on top of the other and there is no chance the shorter chain will ever be longer.</p>

<p>Once that happens, and the longer chain contains one of my two transactions sufficiently deep in the chain, we can all agree which way my bitcoins go. And no central authority is needed.</p>
