Mahavir(Jain GOD) was the contemporary of the Buddha of his time. Buddha did knew some details about Mahavir, Jainism(as its mentioned in the text) & about its own way of enlightenment which he tried only to discover the 'Middle Path'. They even lived & preached in & around the area of 'Vaishali' (ancient city in Indian state Bihar) for certain period of their time.But did they ever met?
No. There is no known record of Gautama Buddha meeting Mahavira (also known as Nigantha Nataputta in the Pali Canon). Jains are known as Niganthas in the Pali Canon.
It appears however that Mahavira was indeed alive but very old at the time of the Buddha according to DN2:
Your majesty, there is Nigantha Nataputta, the leader of a community, the leader of a group, the teacher of a group, honored and famous, esteemed as holy by the mass of people. He is aged, long gone forth, advanced in years, in the last phase of life.
However, there have been examples of the Jains confronting the Buddha and attempting to challenge him.
The teachings of the Buddha and of Jainism are obviously in conflict. You can read about it in this question.
Here is an example from the Devadaha Sutta (MN101):
"When this was said, the Niganthas said to me, 'Friend, the Nigantha Nataputta is all-knowing, all-seeing, and claims total knowledge & vision thus: "Whether I am walking or standing, sleeping or awake, knowledge & vision are continuously & continually established in me." He has told us, "Niganthas, there are evil actions that you have done in the past. Exhaust them with these painful austerities. When in the present you are restrained in body, restrained in speech, and restrained in mind, that is the non-doing of evil action for the future. Thus, with the destruction of old actions through asceticism, and with the non-doing of new actions, there will be no flow into the future. With no flow into the future, there is the ending of action. With the ending of action, the ending of stress. With the ending of stress, the ending of feeling. With the ending of feeling, all suffering & stress will be exhausted." We approve of that [teaching], prefer it, and are gratified by it.'
"When this was said, I said to the Niganthas, 'Friend Niganthas, there are five things that can turn out in two ways in the here-&-now. Which five? Conviction, liking, unbroken tradition, reasoning by analogy, & an agreement through pondering views. These are the five things that can turn out in two ways in the here-&-now. That being the case, what kind of conviction do you have for your teacher with regard to the past? What kind of liking? What kind of unbroken tradition? What kind of reasoning by analogy? What kind of agreement through pondering views?' But when I said this, I did not see that the Niganthas had any legitimate defense of their teaching.
MN 56 is another great sutta, which shows the Buddha not talking directly with Mahavira (Nigantha Nataputta), but through Mahavira's disciples:
At one time the Buddha was staying near Nālandā in Pāvārika’s mango grove. At that time Nigaṇṭha Nāṭaputta was residing at Nāḷandā together with a large assembly of Jain ascetics.
A Jain ascetic called Tapassi had a discussion with the Buddha and then went to Mahavira and relayed the conversation. Hearing this, Mahavira and his wealthy lay benefactor disciple Upali praised Tapassi for explaining Mahavira's teaching to the Buddha. Then, Upali offered to go and debate with and embarrass the Buddha. Tapassi warned him and Mahavira that Upali might get converted by the Buddha's magic. Mahavira said that is impossible and that it is more likely that the Buddha would become Upali's disciple rather than the other way round.
Upali went to debate with the Buddha, but ended up becoming his disciple. The Buddha did not gloat, but rather told Upali to consider his decision carefully and not to stop giving alms to the Jain ascetics that he had supported for a long time. Upali was impressed with the Buddha's kindness and humility. The Buddha taught him the Four Noble Truths.
Later, Upali instructed his gatekeeper to not allow Jain ascetics enter his house, but told his gatekeeper to give them alms. The gatekeeper was however instructed to allow Buddhist monks to enter the house. Hearing this, Mahavira and his large assembly of Jain ascetics visited Upali. Upali let them in, but did not give Mahavira the best seat in his house. Rather, Upali took the best seat. Seeing this and hearing that Upali became the Buddha's disciple, Mahavira became offended and scolded him.
Upali then explained to Mahavira that although Jain teachings look good on the surface, they don't stand up to scrutiny unlike the Buddha's teachings.
Mahavira said to Upali that the king knew the famous and rich Upali to be the disciple of Mahavira, and asked him to confirm who he follows now. Upali sang proses in praise of the Buddha and said he has become the Buddha's disciple now.
The sutta ends like this:
“But when did you compose these praises of the ascetic Gotama’s beautiful qualities, householder?” “Sir, suppose there was a large heap of many different flowers. An expert garland-maker or their apprentice could tie them into a colorful garland. In the same way, the Buddha has many beautiful qualities to praise, many hundreds of such qualities. Who, sir, would not praise the praiseworthy?” Then, unable to bear this honor paid to the Buddha, Nigaṇṭha Nātaputta spewed hot blood from his mouth there and then.
In the Buddhist scriptures there are references to the Buddha or one of his disciples meeting and debating with Jains. In virtually every instance the Buddha or one of his disciples wins the debate and the Jain converts to Buddhism. A less than favorable light is also portrayed to the founder of Jainism, Mahavira. When we compare the vast amount of similarities between the Buddha and Mahavira and Buddhism and Jainism, it is possible that the differences were even less in early Buddhism. A more drastic change may have occurred when Buddhism placed less emphasis on ahimsa as can be seen in Buddhist writings that tend to justify and allow meat eating, for example. It is possible that the early Buddhists were more insistent on vegetarianism as additionally evidenced by King Ashoka who wanted to gradually phase out the killing of animals for food. King Ashoka ruled and lived before the Pali Canon was put to writing. There are marked differences in the definitions of kamma and nibbana (karma and nirvana) and the Buddha was practicing asceticism prior to enlightenment. In light of these facts it is possible that both Mahavira and Buddha were practicing some form of Jainism/Shramana/asceticism and the Buddha got it right (and was the actual new enlightened one to teach the masses, not Mahavira) in regard to nibbana and kamma but both were insistent on ahimsa and many other teachings. https://dhammawiki.com/index.php?title=Buddhism_and_Jainism#Alara_Kalama_and_Udakka_Ramaputa
It appears that Mahavira was a slightly older generation, not quite contemporary.
It is believed that Mahavira was born in early part of the 6th-century BC ... He preached for 30 years, and is believed by Jains to have died in the 6th-century BC. Outside the Jain tradition, scholars such as Karl Potter consider his biographical details as uncertain, with some suggesting he lived in the 5th-century BC contemporaneously with the Buddha.
Other answers on this site suggest that Jainism was already established when the Buddha was teaching, for example,
Well, Buddhism separated itself out as a separate system of thought with the Buddha himself. Jainism must have been a distinct tradition by that time too because the Buddha interacted with the Jains and they are mentioned in the Suttas where they are called the Niganthas.
... and for example,
The Jains were already established and flourishing when the Buddha came on to the scene. There are many places in the suttas where the Buddha debates with Jains and discusses their teachings.
Story of upali or anything for that matter do not appear in any of the Jain texts which are equally relevant and even older, it's insane that such stories exists in Buddhist texts while it's historically proven and accepted worldwide that Mahavira was an older contemporary and quite established by the time Buddha came to know of even basics. Poor Buddha didn't know that the already enlightened master that he reverred while alive left to such derogation by his own followers later to his death.
There is an argument that proposes that Buddha and Mahavira (Jain chief) were not contemporaries at all. The same article suggests that Buddha's lifetime predates Mahavira. According to the author, the confusion can be attributed to colonial mishandling of key figures and dates during the translation of Pali/Sanskrit texts to English.
Some of the key points included:
- the moniker Nigantha Nātaputta was wrongly attributed to Mahavira
- Gosala, a companion of Mahavira, was juxtaposed with a similarly named contemporary of Buddha named Makkhali Goshaliputta (possibly a Shaivite, or Ajivika sect)
- the ruler Bimbisara (a contemporary of Buddha) was conflated with king Srenika (also known as Bhambhasara), who appeared during Mahavira's time; although both ruled the Magadha kingdom
The historian puts Mahavira's nirvana around 1189 BCE instead of 529 BCE, and Buddha's nirvana at 1864 BCE not 487 BCE.
Although the dissertation is not composed well, it makes an interesting argument. It can be downloaded here.