Apart from fielding a joint women's ice hockey team, Seoul's Unification Ministry said the two countries would march together under a blue and white "unification flag" depicting their peninsula in the February 9 opening ceremony.
The two nations will also field a united team in the women's ice hockey when the Games get underway in Pyeongchang on February 9, the International Olympic Committee said in a statement.
Separately, South Korea's Unification Ministry said North Korea would send a delegation to the country on Sunday to prepare for a trip by an art troupe during the Games, pushing the visit back a day after earlier cancelling it. The North will send 24 officials and 21 media representatives.
The governments of North and South Korea were offered "sincere thanks" by IOC President Thomas Bach announcing the agreement.
In his remarks, Bach said the International Olympic Committee had been working for several years to address the "special situation" of having the 2018 Winter Olympics on the Korean Peninsula.
The agreement became possible after North Korean leader Kim Jong Un said three weeks ago that a team could cross the border to compete.
"The Olympic Winter Games are hopefully opening the door to a brighter future on the Korean peninsula".
"It is not the time to ease pressure or to reward North Korea", Japan foreign minister Taro Kono said.
The momentum toward strengthening sanctions on North Korea must not be lost just because of a heightened mood of reconciliation prompted by the Winter Olympics.
North Korean athletes will also compete in figure skating, short track speed skating, alpine and cross-country skiing.
North Korea took up Moon's invitation to participate just before the Olympics start because it aims to open a hole in the web of sanctions imposed by the worldwide community and escape from its isolation.
However, the decision to field a unified ice hockey team has sparked a sharp backlash in the South, including from younger South Koreans upset that an unchastened North Korea is taking the spotlight.
The IOC said it would provide any necessary equipment for the athletes.
Regardless of where its athletes sleep, the North is unlikely to pose a significant threat in competition, as the country has only won two medals in the history of the Winter Games, in 1964 and 1992, both for speedskating.
The hockey team will compete as "Korea", under the unification flag and using the song "Arirang" as its anthem.