The miner completes the proof-of-work.
The network is decentralized. There is no single server that is "in charge" to resolve conflicts.
The proof-of-work is how the network resolves conflicts and reaches a consensus on the order of transactions.
Imagine that there are no miners and a user creates a transaction. Imagine that the user creates his own block and adds the transaction to that block. Now imagine that the user creates a second transaction that spends the exact same bitcoins. Imagine that the user creates a second block at the same height as his other block but with this other transaction instead. Now imagine that the user sends one of those blocks to half of the nodes on the network, and the other block to the other half of the nodes. How would the network decide which is the "real" transaction and which is invalid?
Mining solves this problem.
It takes time and effort to "solve a block". The work is done in such a way that the distribution of solved blocks is approximately equal to the miners percentage of the global work being done. So if a miner has 10% of the global hash power, then he will (on average) solve only 10% of the blocks.
Let's imagine that the same person above is a miner in the system the way it exists today. Let's immagine that he controls 10% of the global hash power. He completes the proof-of-work on the first block. During the time that is takes for him to complete the second block, the rest of the netowrk is (on average) going to solve 9 more blocks. This leaves him with a choice to make.
1) He can broadcast his first solved block immediately, as soon as he solves it. If he does this, he gets to keep the block reward and fees of all transactions that he includes in the block. However, by doing so, the entire network will hear about his first block LONG before he ever solves the second block. This means that the entire network will already have accepted that the first transaction is the "real" transaction. The second block will be considered invalid and will be rejected by everyone.
2) He can withhold the first block until he solves the second block. If he does this, 9 other blocks will already have been added to the chain since he created his two blocks. The "valid" chain will extend 8 blocks higher than the the height of his two blocks. Since the network follows the longest chain, his two blocks will BOTH be rejected by everyone. He'll lose out on the block reward and fees, and he still failed to confuse the network with two incompatible transactions.
In either case, the entire network agrees on the history of the blockchain. They've reached consensus. Unless someone controls more hash power than the entire rest of the world combined, they can't divert the nodes and confuse the system about which transactions and blocks are "valid".
That makes sense. Thank you for such a clear answer. I have a lot of work to do in order to understand all this, but it's a lot of fun.