Hungary–Romania relations
During World War II, Hungary and Romania became allies and participated in the war against the Soviet Union. But after the coup on 23 August 1944 Romania switched sides and fought against Hungary. Consequently, Soviet and Romanian troops invaded Hungary, occupied Northern Transylvania by October 1944 and re-established the Romanian administration in the region in March 1945. The 1947 Treaty of Paris reaffirmed the borders between Romania and Hungary as originally defined in Treaty of Trianon 27 years earlier, thus confirming the return of Northern Transylvania to Romania.
World War I
Romania had been allied with the Central Powers since 1882. When the war began, however, it declared its neutrality, arguing that because Austria-Hungary had itself declared war on Serbia, Romania was under no obligation to join the war. On August 4, 1916, Romania and the Entente signed the Political Treaty and Military Convention, that established the coordinates of Romania's participation in the war. In return, it received the Allies' formal sanction for Transylvania, Banat and other territories of Austria-Hungary to be annexed to Romania. The action had large popular support. On 27 August 1916, the Romanian Army launched an attack against Austria-Hungary, with limited Russian support. The Romanian offensive was initially successful in Transylvania, but a Central Powers counterattack by the drove them back. As a result of the Battle of Bucharest, the Central Powers occupied Bucharest on 6 December 1916. Fighting in Moldova continued in 1917, but Russian withdrawal from the war in late 1917 as a result of the October Revolution meant that Romania was forced to sign an armistice with the Central Powers on 9 December 1917.