There is relation between Hungarian and other Ugric languages (mainly Khanty, Mansi). Ugric languages are in turn related with Finnic languages (mainly Finnish and Estonian).

That is why it is called Finno-Ugric language group, which scientists divide into two subgroups, Finnic and Ugric.
As they are related, it is much probable that they originated from dialect(s) spoken by the same group of people millenia ago.

That is theory indeed, but some linguistics have abandoned this theory, since they claim there is not enough evidence to prove definite link between languages (like how some propose proto-Iberian link between Georgian and Basque, or Romanian and Albania due to proposed Paleo-Balkan link, maybe there is link, maybe not).

I read somewhere that there are something like 600 shared words between Finnish and Hungarian, but this linguist for example criticizes how common they are: http://www.magtudin.org/Maracz%20L.%20Untenability%20of%20Finno-Ugric%20Theory.htm.

Sure, there is possible some very distant ancient common root of this peoples, but today, there is not definite evidence that this Ugric and Finnic languages are related (as for example Indo-European languages are), according to some linguists (though some maintain there is link). It is never that easy with languages though. I have heard Turanian theories claiming link between all Uralic and Altaic languages with both Korean and Japanese languages.

In any case, this going off topic little bit, how related Finnish and Hungarian are. Criticism was more of Turanian theory claiming that Finnish and Hungarian are related to Turkic, Mongol and even Japanese and Korean languages.