You do not give any time frame for when you are talking about, so I will just guess that you are talking about what happened during World War II. During that time, the Nationalists and the Communists formed a temporary united front against the Japanese.
During this time, the two sides were really not allies, but I suppose that you could say they were aligned with each other because they were more interested in fighting the Japanese than each other. They still fought each other now and then during this time, but most of the time they cooperated in their attempt to get rid of the Japanese.
The Communist Party co-operated with the Nationalist Party during World War II as both sides sought to put aside their ideological differences for the time being to repel the Japanese from their homeland. The collaboration between the two parties, however, were often merely superficial in nature. The Nationalist Party government was inherently corrupt - supplies provided by the Allies were often not used for war efforts against the Japanese, but were rather stockpiled in preparation for future campaigns against the communists. Similarly, both parties pursued two drastically different military policies in regards to the Japanese invasion. In response to Japanese aggression, the Nationalist Party strategy was essentially a policy of retreat, whereby space would be traded for time. On the other hand, the communists, in the form of the Eighth Route Army, actively resisted against the Japanese, by seeking to infiltrate the enemy forces and setting up ambushes.