Anthony Kulkamp Dias, 33, was conscious during his operation to remove a tumour and played the instrument for the surgery team. His serenade allowed doctors to avoid hitting areas of his brain that control senses, movement and speech.
Mr Kulkamp, a bank worker, started with Emanuel, a song he wrote for his newborn son, before playing the classic Beatles hit.
He later played some Brazilian country songs during the procedure last week at the Nossa Senhora de Conceição Hospital in the southern state of Santa Catarina.
'The doctors asked me to repeat the country song so I even had an encore,' he told Brazilian news website G1.