South Korean President Moon Jae-in and North Korean leader Kim Jong Un reached the agreement during several exchanges of letters since April, the presidential office in Seoul said.
North and South Korea have said they had restored cross-border communications, more than a year after Pyongyang severed all official hotlines between the two rivals, who technically remain at war.
The North unilaterally cut off all official military and political communication links with the South in June last year after threats over activists sending anti-Pyongyang leaflets over the border.
The suspension came with inter-Korean ties at a standstill, despite three summits between the North's Kim Jong-un and the South's President Moon Jae-in in 2018.
But in a surprise announcement, the two sides said all communication lines were restored on Tuesday morning.
"According to the agreement made between the top leaders, the north and the south took a measure to re-operate all inter-Korean communication liaison lines from 10:00 [0100 GMT] on July 27," the North's official KCNA news agency reported.
Restoring mutual trust
The leaders of the two Koreas have exchanged personal letters since April aimed at improving ties, Moon's office said in a statement, and agreed to restore the hotlines as the first step.
"The two leaders also agreed to restore mutual trust between the two Koreas as soon as possible and move forward with the relationship again," it added.
The dovish South Korean president is credited with brokering the first-ever summit between North Korea and a sitting US president in Singapore in June 2018.
But Pyongyang largely cut off contact with Seoul following the collapse of a second summit between Kim and then US president Donald Trump in Hanoi that left nuclear talks at a standstill.
Kim has since threatened to bolster his nuclear arsenal and build more sophisticated weapons unless the Americans lifts policies the North considers hostile – believed to refer to the longstanding US-led sanctions.