The Seoul meeting was the first direct talks since 1992 between the prime ministers of the two Koreas, which are still technically at war.
The rail service, limited to cargo, will start on December 11 on a 25-km track to a joint industrial complex in the city of Kaesong near the North Korean border about 70km northwest of Seoul.
The move is part of measures the two Koreas are taking to boost joint development plans in the border industrial zone.
"At last the leaders of both republics have enough guts to leap over their differences and remember their bloodline"
Send us your views
A statement from Han's office said: "The agreements set the stage for our companies to expand investment in the North and substantially contribute to its economic development."
Friday's agreement also called on Seoul to build shipyards in North Korea as well as repair a major highway and railway line in the impoverished country next year.
The prime ministers also agreed to promote co-operation in agriculture, resources development and medical sectors, as well as plan more reunions of families separated by the 1950-53 Korean War.
Both sides will also set up a joint fishing area around the disputed Yellow Sea border to prevent deadly naval clashes like those seen in 1999 and 2000.
Lee Jae-joung, the South Korean unification minister, said economists estimate that the project costs could run into billions of dollars.
Easing internet restrictions
Pyongyang also agreed to allow South Koreans to use the internet and mobile phones inside the Kaesong area.
Internet use in North Korea is normally limited to elite officials.
Visitors to North Korea have to hand over foreign mobile phones upon entry and pick them up only when they are leaving.
"The commitments of the two leaders are strong, so the environment and conditions for implementing the agreement in full are there," Lee said at the end of the three-day talks.