The Abhidharma (Sanskrit) or Abhidhamma (Pali) is an analysis of Buddhist teaching that is among the most important texts of early Buddhism. As the Abhidharma-pitaka, it is the third of three sections or "baskets" of the Tipitika. It is said that the two other sections, the Vinaya-pitaka and the Sutra-pitaka, provide practical guidance for following the Buddhist path, while the Abhidharma presents the theoretical framework that explains how the teachings "work."
When we talk about the Abhidharma, we must keep in mind that we are talking about two different texts. It appears that at one time there were other versions of the Abhidharma, but only two survive intact today. One of these usually is called the Sarvastivada Abhidharma, and it is associated with Mahayana Buddhism. The other is the Theravada Abhidhamma, obviously associated with Theravada Buddhism. Origin of the Abhidharma
According to Buddhist tradition, four weeks after he realized enlightenment the historical Buddha composed the Abhidharma in his mind. Seven years later, he spent three months preaching the Abhidharma to thousands of devas (godlike beings,sort of) in one of the deva realms.
After his talks he would return to the human world and dictate a condensed version of his talk to Sariputra, who wrote it down and mastered it. The Abhidharma was added to the Tipitika during the Third Buddhist Council (ca. 250 BCE).
Scholars have a different version of this story. It's not clear exactly when the Abhidharma was written or who wrote it, but it probably does not date to the time of the historical Buddha. Scholars believe composition began about 300 BCE,and at first it probably was a collection of commentaries on the Buddha's sermons. However, neither version was completely finished until a few centuries later.
How much later? Some scholars believe the Theravada Abhidhamma was finalized by Buddhaghosa (ca. 5th century CE) although that is not certain. The final form of the Sarvastivada Abhidharma may date to the time of Vasubandhu (ca. 4th century CE), but again, that is not certain.
Early Buddhist history has defied scholarly reconstruction, so there is much we don't know. What we do know is that by the 3rd century BCE, when composition of the Abhidharma likely bagan, Buddhism was breaking up into distinctive sects with doctrinal differences.
One of these sects was the Schavira (roughly, "adherent of the elders"), forerunner of today's Theravada. Sarvastivada ("the teaching that everything is") was a sub-school of Schavira that split away. According to some accounts, this split took place during the time of Ashoka the Great (304-232 BCE). It's more likely the split occurred near the end 1st century BCE, however.
The Sarvastivadas developed many views of dharma that the main sect of Schavira/Theravada rejected, but which later would influence Mahayana Buddhism. Much of this influence is attributed to the 4th century CE monk Vasubandhu, who trained in the Sarvastivada tradition and then converted to Mahayana. While still in the Sarvastivada school, Vasubandhu wrote a commentary on the Abhidharma called the Abhidharma-kosa ("treasury of Abhidharma") that was adopted and studied by several early Mahayana schools. Vasubandhu also was one of the founders of Yogacara philosophy, and he is revered as a patriarch in both the Pure Land and Zen traditions.
Very basically, the two Abhidharmas both discuss the natural processes that connect mental and physical phenomena. Both works analyze phenomena by breaking them down into momentary events that cease to exist as soon as they occur. Beyond that, however, the two texts presents different understandings of the nature of time and matter,which account for the divergence.
Neither Abhidharma is a "beginner-level" text. They are both sophisticated works presenting systemic analyses of some of the most difficult teachings of Buddhism. If you wish to study either of them, the guidance of a master teacher is highly recommended.